-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
71 lines (62 loc) · 1.81 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
var util = require('util');
var glob = require('glob');
var moment = require('moment');
var config = require('./config');
module.exports = function (grunt) {
var filesToSkip = ['Gruntfile.js'];
var filePaths = glob.sync('*.js', {cwd: 'src/'}).filter(function (filePath) {
return filesToSkip.indexOf(filePath) < 0;
});
var files = function (env) {
return filePaths.reduce(function (files, filePath) {
files[util.format('bin/%s/%s', env, filePath)] = 'src/' + filePath;
return files;
}, {});
};
function get_config(name) {
var conf = config[name];
conf.buildDate = moment().format();
return conf;
}
grunt.initConfig({
jshint: {
all: ['bin/**/*.js']
},
render: {
dev: {
options: get_config('dev'),
files: files('dev')
},
production: {
options: get_config('production'),
files: files('production')
},
staging: {
options: get_config('staging'),
files: files('staging')
}
},
deploy: {
dev: {
options: get_config('dev')
},
staging: {
options: get_config('staging')
},
production: {
options: get_config('production')
}
}
});
grunt.loadTasks('tasks/');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-ejs-render');
grunt.registerTask('default', ['render:dev']);
grunt.registerTask('dev', ['render:dev']);
grunt.registerTask('production', ['render:production']);
grunt.registerTask('staging', ['render:staging']);
grunt.registerTask('rd', ['render:dev', 'deploy:dev']);
grunt.registerTask('rd-dev', ['render:dev', 'deploy:dev']);
grunt.registerTask('rd-production', ['render:production', 'deploy:production']);
grunt.registerTask('rd-staging', ['render:staging', 'deploy:staging']);
};