forked from jsdelivr/bootstrapcdn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.js
181 lines (148 loc) · 4.55 KB
/
make.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
'use strict';
require('shelljs/make');
var path = require('path');
var http = require('http');
var fs = require('fs');
var MOCHA = path.join(__dirname, 'node_modules/.bin/mocha');
var BOOTLINT = path.join(__dirname, 'node_modules/.bin/bootlint');
var VALIDATOR = path.join(__dirname, 'node_modules/.bin/html-validator');
var FOREVER = path.join(__dirname, 'node_modules/.bin/forever');
(function() {
cd(__dirname);
function assert(result) {
if (result.code !== 0)
process.exit(result.code);
}
function assertExec(cmd) {
assert(exec(cmd));
}
//
// make test
//
target.test = function() {
assertExec(MOCHA + ' --timeout 15000 ./tests/*_test.js ./tests/**/*_test.js -R spec');
};
//
// make test-nc
//
target['test-nc'] = function() {
assertExec(MOCHA + ' --no-colors --timeout 15000 ./tests/*_test.js ./tests/**/*_test.js -R spec');
};
//
// make clean
//
target.clean = function() {
rm('-rf', 'node_modules');
};
//
// make run
//
target.run = function() {
assertExec('node app.js');
};
// for integration tests
target.start = function() {
assertExec(FOREVER + ' --plain start app.js');
};
target.stop = function() {
assertExec(FOREVER + ' stop app.js');
};
//
// make travis
//
target.travis = function() {
target.test();
target.bootlint();
target.validator();
};
//
// make wp-plugin
//
target['wp-plugin'] = function() {
echo('node ./scripts/wp-plugin.js');
assertExec('node ./scripts/wp-plugin.js');
};
target['purge-latest'] = function() {
// TODO: Make pure JS
echo('bash ./scripts/purge.sh');
assertExec('bash ./scripts/purge.sh');
};
//
// make bootlint
//
target.bootlint = function() {
echo('+ node make start');
var port = 3080;
env.PORT = port;
target.start();
// sleep
setTimeout(function() {
var output = path.join(__dirname, 'lint.html');
var file = fs.createWriteStream(output);
// okay, not really curl, but it communicates
echo('+ curl http://localhost:' + port + '/ > ' + output);
var request = http.get('http://localhost:' + port + '/', function(response) {
response.pipe(file);
response.on('end', function() {
file.close();
echo('+ bootlint ' + output);
// disabling version error's until bootswatch is updated to 3.3.4
var res = exec(BOOTLINT + ' -d W013 ' + output);
echo('+ node make stop');
target.stop();
rm(output);
assert(res);
});
});
}, 2000);
};
//
// make validator
//
target.validator = function() {
echo('+ node make start');
var port = 3080;
env.PORT = port;
target.start();
// sleep
setTimeout(function() {
var output = path.join(__dirname, 'index.html');
var file = fs.createWriteStream(output);
// note; url version is failing due to a connection error, odd.
// okay, not really curl, but it communicates
echo('+ curl http://localhost:' + port + '/ > ' + output);
var request = http.get('http://localhost:' + port + '/', function(response) {
response.pipe(file);
response.on('end', function() {
file.close();
echo('+ html-validator ' + output);
var res = exec(VALIDATOR + ' --file=' + output);
echo('+ node make stop');
target.stop();
rm(output);
assert(res);
});
});
}, 2000);
};
//
// make all
//
target.all = function() {
target.test();
target.run();
};
//
// make help
//
target.help = function() {
echo('Available targets:');
echo(' all test and run');
echo(' test runs the tests');
echo(' test-nc runs the tests w/o colors');
echo(' clean cleanup working directory');
echo(' run runs for development mode');
echo(' bootlint run Bootlint locally');
echo(' help shows this help message');
};
}());