-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
94 lines (89 loc) · 2.45 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* js-data-nedb
* https://github.com/js-data/js-data-nedb
*
* Copyright (c) 2014-2015 Jason Dobry <http://www.js-data.io/docs/dsnedbadapter>
* Licensed under the MIT license. <https://github.com/js-data/js-data-nedb/blob/master/LICENSE>
*/
module.exports = function (grunt) {
require('jit-grunt')(grunt, {
coveralls: 'grunt-karma-coveralls'
});
require('time-grunt')(grunt);
var pkg = grunt.file.readJSON('package.json');
// Project configuration.
grunt.initConfig({
pkg: pkg,
watch: {
dist: {
files: ['src/**/*.js'],
tasks: ['build']
}
},
coveralls: {
options: {
coverage_dir: 'coverage'
}
},
mochaTest: {
all: {
options: {
reporter: 'spec'
},
src: ['mocha.start.js', 'test/**/*.js']
}
},
webpack: {
dist: {
debug: true,
entry: './src/index.js',
output: {
filename: './dist/js-data-nedb.js',
libraryTarget: 'commonjs2',
library: 'js-data-nedb'
},
externals: [
'mout/array/map',
'mout/array/unique',
'js-data',
'nedb'
],
module: {
loaders: [
{ test: /(src)(.+)\.js$/, exclude: /node_modules/, loader: 'babel-loader?blacklist=useStrict' }
],
preLoaders: [
{
test: /(src)(.+)\.js$|(test)(.+)\.js$/, // include .js files
exclude: /node_modules/, // exclude any and all files in the node_modules folder
loader: "jshint-loader?failOnHint=true"
}
]
}
}
}
});
grunt.registerTask('standard', function () {
var child_process = require('child_process');
var done = this.async();
grunt.log.writeln('Linting for correcting formatting...');
child_process.exec('node node_modules/standard/bin/cmd.js --parser babel-eslint src/index.js', function (err, stdout) {
console.log(stdout);
if (err) {
grunt.log.writeln('Failed due to ' + (stdout.split('\n').length - 2) + ' lint errors!');
done(err);
} else {
grunt.log.writeln('Done linting.');
done();
}
});
});
grunt.registerTask('n', ['mochaTest']);
grunt.registerTask('test', ['build', 'n']);
grunt.registerTask('build', [
'standard',
'webpack'
]);
grunt.registerTask('go', ['build', 'watch:dist']);
grunt.registerTask('default', ['build']);
};