-
Notifications
You must be signed in to change notification settings - Fork 21
/
setup.js
29 lines (25 loc) · 1.04 KB
/
setup.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
var exec = require('child_process').exec;
var sysPath = require('path');
var fs = require('fs');
var mode = process.argv[2];
var fsExists = fs.exists || sysPath.exists;
var execute = function(pathParts, params, callback) {
if (callback == null) callback = function() {};
var path = sysPath.join.apply(null, pathParts);
var command = 'node ' + path + ' ' + params;
console.log('Executing', command);
exec(command, function(error, stdout, stderr) {
if (error != null) return process.stderr.write(stderr.toString());
console.log(stdout.toString());
});
};
if (mode === 'postinstall') {
fsExists(sysPath.join(__dirname, 'lib'), function(exists) {
if (exists) return;
execute(['node_modules', 'coffee-script', 'bin', 'coffee'], '-o lib/ src/');
});
} else if (mode === 'test') {
execute(['node_modules', 'coffee-script', 'bin', 'coffee'], '-o lib/ src/');
execute(['node_modules', 'mocha', 'bin', 'mocha'],
'--require test/common.js --require coffee-script --compilers coffee:coffee-script --colors -R \'spec\' --ui \'bdd\'');
}