-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
75 lines (67 loc) · 2.33 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
'use strict';
module.exports = function(grunt) {
var opts = {
clean: [
'./build'
],
jshint: {
browser: {
files: {
src: ['src/**/*.js', '!src/vendor/**/*.js']
},
options: {
jshintrc: '.jshintrc'
}
},
node: {
files: {
src: ['Gruntfile.js', 'test/**/*.js']
},
options: {
jshintrc: '.jshintrc-node'
}
}
},
jasmine_node: {
matchall: true,
forceExit: true,
projectRoot: './test/spec'
},
assetify: {
options: {
production: true,
assets: require('./assets.js'),
plugins: {
bundle: true
}
}
}
};
grunt.initConfig(opts);
grunt.loadNpmTasks('grunt-assetify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jasmine-node');
grunt.registerTask('test', ['clean', 'jshint', 'jasmine_node']); // cleanup and run tests
grunt.registerTask('build', ['assetify']); // compile assets
grunt.registerTask('default', ['test', 'build']); // by default, run the tests and build
grunt.registerTask('demo', 'A task to run the demo server', function(){
var done = this.async(),
http = require('http'),
sta = require('node-static'),
staServer = new sta.Server();
http.createServer(function(req, res){
staServer.serve(req, res, function (err, result) {
if (err) {
console.error("> Error serving " + req.url + " - " + err.message);
res.writeHead(err.status, err.headers);
res.end();
} else {
console.log("> " + req.url + " - " + result.message);
}
});
}).listen(5050, function(){
console.log('Navigate to localhost:5050/demo/development.html or localhost:5050/demo.production.html');
}).on('close', done);
});
};