-
Notifications
You must be signed in to change notification settings - Fork 1
/
grunt.js
137 lines (127 loc) · 3.63 KB
/
grunt.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// grunt.js (c) 2010-2013 Loren West and other contributors
// May be freely distributed under the MIT license.
// For all details and documentation:
// http://lorenwest.github.com/monitor-min
var exec = require('child_process').exec;
// This is used in the build automation tasks, and on the server
// when running in dev mode to serve individual files for debugging.
var MODULE_DEF = {
lib: [
"lib/Monitor.js",
"lib/Stat.js",
"lib/Log.js",
"lib/Probe.js",
"lib/Connection.js",
"lib/Server.js",
"lib/Router.js",
"lib/Sync.js",
"lib/probes/PollingProbe.js",
"lib/probes/StreamProbe.js",
"lib/probes/InspectProbe.js",
"lib/probes/StatProbe.js",
"lib/probes/LogProbe.js"
],
ext: [
"node_modules/underscore/underscore.js",
"node_modules/backbone/backbone.js",
"node_modules/backbone-callbacks/backbone-callbacks.js",
"node_modules/socket.io-client/dist/socket.io.js"
],
probes: [
"lib/probes/FileProbe.js",
"lib/probes/ReplProbe.js",
"lib/probes/ProcessProbe.js",
"lib/probes/SyncProbe.js",
"lib/probes/FileSyncProbe.js"
]
};
// Build automation tasks
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: '<json:package.json>',
monitor: MODULE_DEF,
meta: {
banner: '/* <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> */'
},
lint: {
files: ['grunt.js', '<config:monitor.lib>', '<config:monitor.probes>', 'test/*.js']
},
test: {
files: ['test/*.js']
},
watch: {
files: ['grunt.js', 'yuidoc.json', '<config:monitor.lib>', '<config:monitor.probes>', 'config/doc/**', 'test/*.js'],
tasks: 'doc lint test'
},
concat: {
lib: {
src: ['<banner>', '<config:monitor.lib>'],
dest: './dist/monitor-min.js'
},
all: {
src: ['<banner>', '<config:monitor.ext>', '<config:monitor.lib>'],
dest: './dist/monitor-min-all.js'
}
},
min: {
lib: {
src: ['<banner>', './dist/monitor-min.js'],
dest: './dist/monitor-min.min.js'
},
all: {
src: ['<banner>', './dist/monitor-min-all.js'],
dest: './dist/monitor-min-all.min.js'
}
},
jshint: {
options: {
strict: false,
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
node: true
},
globals: {
exports: true
}
}
});
grunt.registerTask('doc', 'Generate documentation files', function() {
var t = this, done = t.async(), child, version = grunt.config.get('pkg').version;
var cmd = 'yuidoc --project-version ' + version;
console.log(cmd);
child = exec(cmd, function (error, stdout, stderr) {
console.log(stderr);
console.log(stdout);
cmd = 'cp -R doc/* ../lorenwest.github.com/monitor-min';
console.log(cmd);
child = exec(cmd, function (error, stdout, stderr) {
console.log(stderr);
console.log(stdout);
done();
});
});
});
grunt.registerTask('rm_dist', 'Remove distribution files', function() {
var t = this, done = t.async(), child;
child = exec('rm -f dist/*', function (error, stdout, stderr) {
console.log(stderr);
console.log(stdout);
done();
});
});
// Default task.
grunt.registerTask('default', 'doc lint test dist');
grunt.registerTask('dist', 'rm_dist concat:lib concat:all min:lib min:all');
};
// Expose externally
module.exports.MODULE_DEF = MODULE_DEF;