-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathgrunt.js
155 lines (139 loc) · 4.14 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
module.exports = function(grunt) {
var exec = require('child_process').exec,
async = require('async');
// Project configuration.
grunt.initConfig({
lint: {
grunt: 'grunt.js',
tests: 'test/*.js',
lib: 'lib/*.js',
//slowly adding all of these
demos: [
'demos/paranoid/scripts/*.js',
'demos/rock-piano/scripts/*.js',
'demos/svg-speedtest/scripts/*.js',
'demos/tatami/scripts/*.js',
'demos/touch-tracker/scripts/*.js',
'demos/warholiser/scripts/*.js',
'demos/border-radius-fun/scripts/*.js',
'demos/border-salon/scripts/*.js',
'demos/clock/scripts/*.js',
'demos/color-picker/scripts/script.js',
'demos/cracked/scripts/*.js',
'demos/explode/scripts/*.js',
'demos/fence/scripts/*.js'
],
shared: 'source/scripts/panel.js'
},
// have a look at http://www.jshint.com/docs/ to understand these
jshint: {
// Defaults.
options: {
curly: true, newcap: true, bitwise: true, forin: true, latedef: true, strict: false
},
grunt: {
options: {node: true, strict: false}
},
tests: {
options: {node: true, loopfunc: true, boss: true, strict: false}
},
lib: {
options: {browser: true, boss: true}
},
shared: {
options: {shadow: true, expr: true}
},
demos: {
options: {smarttabs: true, sub:true, browser:true, shadow: true, expr: true, strict: false}
}
}
});
// Default task.
grunt.registerTask('default', 'lint');
grunt.registerTask('deploy', 'Deploy the site', function(){
var done;
if (this.args[0] == "dev") {
done = this.async();
grunt.log.writeln('Deploying the site to ' + 'dev.shinydemos.com'.green);
exec('node ../shinydemos-misc/deploy.js --env=dev', function(){
done();
});
} else if (this.args[0] == "prod") {
done = this.async();
grunt.log.writeln('Deploying the site to ' + 'shinydemos.com'.green);
exec('node ../shinydemos-misc/deploy.js --env=prod', function(){
done();
});
} else {
grunt.log.writeln('Unknown deploy target'.red);
return false;
}
});
grunt.registerTask('test', 'Run unit tests', function(){
var done = this.async(),
pass = true;
if (this.args[0] == "config") {
async.parallel([
function(callback){
//it seems that running a vows test via `node` doesn't emit
//an error object, so this is a regexy hack around that
exec('node test/config-demos-test.js', function (error, stdout, stderr) {
grunt.log.writeln(stdout);
callback(error, (/✗/.exec(stdout) !== null));
});
},
function(callback){
exec('node test/config-features-test.js', function (error, stdout, stderr) {
grunt.log.writeln(stdout);
callback(error, (/✗/.exec(stdout) !== null));
});
},
function(callback){
exec('node test/config-siteconfig-test.js', function (error, stdout, stderr) {
grunt.log.writeln(stdout);
callback(error, (/✗/.exec(stdout) !== null));
});
},
function(callback){
exec('node test/config-tags-test.js', function (error, stdout, stderr) {
grunt.log.writeln(stdout);
callback(error, (/✗/.exec(stdout) !== null));
});
},
function(callback){
exec('node test/config-demos-tags-test.js', function (error, stdout, stderr) {
grunt.log.writeln(stdout);
callback(error, (/✗/.exec(stdout) !== null));
});
}],
function(err, results){
//if there's an error in one of the tests, the results array
//will have a true in it somewhere. so to pass, you should not
//have any match via [].indexOf()
pass = (results.join().indexOf('true') === -1);
done(pass);
});
} else {
exec('vows', function (error, stdout, stderr) {
grunt.log.writeln(stdout);
if (error) {
//if the test suite errors, pass will be false
pass = (error.code === 0);
}
//now grunt can let us know we failed
done(pass);
});
}
});
grunt.registerTask('build', 'FIRE ZE MISSLES', function(){
var done = this.async(),
pass;
exec('node ./index.js', function(error, stdout, stderr){
grunt.log.writeln(stdout);
if (error) {
pass = (error.code === 0);
}
done(pass);
});
});
};