-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathgruntfile.js
103 lines (81 loc) · 2.9 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
95
96
97
98
99
100
101
102
103
// Copyright (c) 2013 - present UTN-LIS
/* eslint global-require: 0 */
module.exports = function (grunt) {
'use strict';
require('load-grunt-tasks')(grunt);
// Project configuration.
grunt.initConfig({
buildConfig: {
name: 'pumascript',
output: 'dist/<%= buildConfig.name %>'
},
eslint: {
options: {
configFile: '.eslintrc.js',
format: 'stylish'
},
target: [
'./editor/*.js',
'./src/**/*.js',
'./test/**/*.js'
]
},
exec: {
webpack: {
cmd: 'node ./node_modules/webpack/bin/webpack.js --config webpack.config.js'
},
qunit:{
cmd: 'node ./node_modules/node-qunit-phantomjs/bin/node-qunit-phantomjs test/test.html'
},
ci:{
cmd: 'node ./node_modules/node-qunit-phantomjs/bin/node-qunit-phantomjs test/test.html --verbose'
}
},
uglify: {
dist: {
options: {
sourceMap: true,
sourceMapName: 'dist/pumascript.min.map',
sourceMapIn: 'dist/pumascript.map'
},
files: {
'dist/pumascript.min.js': [ 'dist/pumascript.js' ]
}
}
},
clean: {
tests: ['tmp'],
dist: ['dist']
}
});
grunt.registerTask('init', 'Prepare to start working with Puma', function () {
// Use spawn to report progress of the task
var exec = require('child_process').exec;
var cmd = exec('npm install', { cwd: './editor' });
var done = this.async();
cmd.stdout.on('data', function (data) {
grunt.log.write(data.toString());
});
cmd.stderr.on('data', function (data) {
grunt.log.error('Error: ' + data.toString());
});
cmd.on('exit', function (code) {
if (code > 0) {
grunt.fail.fatal('Process Finished Code: ' + code.toString());
} else {
grunt.log.ok('Process Finished Code: ' + code.toString());
}
//Grunt init tasks ends with an "Done, with errors" message due
//to the forecoming sentence
done();
});
});
grunt.registerTask('build-dev', ['clean:dist', 'exec:webpack']);
grunt.registerTask('build', ['build-dev', 'uglify:dist']);
// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
grunt.registerTask('test', ['clean', 'exec:webpack', 'exec:qunit']);
grunt.registerTask('test-ci', ['clean', 'exec:webpack', 'exec:ci']);
grunt.registerTask('travis', ['eslint', 'test-ci']);
grunt.registerTask('default', ['init']);
};