-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
executable file
·76 lines (55 loc) · 1.4 KB
/
test.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
#!/usr/bin/env node
// based on https://github.com/kjbekkelund/js-build
require('shelljs/make');
require('colors');
var npmBin = require('npm-bin');
var glob = require('glob');
var path = require('path');
var isWin = (process.platform === 'win32');
/*** CONFIG ********/
var webapp = path.join('src'),
config = path.join('config'),
jshintConfig = path.join(config, 'jshint.json');
/*** TARGETS ********/
target.all = function() {
target.jshint();
target.test();
};
target.jshint = function() {
var files = glob.sync(path.join(webapp, '*.js'));
files.push(path.join('bin', 'imageinliner'));
section('Running JSHint');
bin('jshint', ['--config ' + jshintConfig, files.join(' ')]);
};
target.test = function() {
bin('mocha');
// echo();
// done(res);
};
/*** HELPERS ********/
var bin = function(name, arguments, options) {
var res = npmBin(name, arguments, options)
done(res);
};
var done = function(res) {
if (res.code === 0) {
success();
} else {
fail();
}
};
var section = function(header) {
echo();
echo(' ' + header.bold);
};
var success = function(text) {
text = text || 'done';
var s = isWin ? '»' : '✓';
echo(' ' + s.green + ' ' + text.green);
};
var fail = function(text) {
text = text || 'failed';
var s = isWin ? '×' : '✘';
echo(' ' + s.red + ' ' + text.red);
exit(1);
};