1 | var exec = require('child_process').exec;
|
2 | var sysPath = require('path');
|
3 | var fs = require('fs');
|
4 |
|
5 | var mode = process.argv[2];
|
6 |
|
7 | var fsExists = fs.exists || sysPath.exists;
|
8 |
|
9 | var execute = function(pathParts, params, callback) {
|
10 | if (callback == null) callback = function() {};
|
11 | var path = sysPath.join.apply(null, pathParts);
|
12 | var command = 'node ' + path + ' ' + params;
|
13 | console.log('Executing', command);
|
14 | exec(command, function(error, stdout, stderr) {
|
15 | if (error != null) return process.stderr.write(stderr.toString());
|
16 | console.log(stdout.toString());
|
17 | });
|
18 | };
|
19 |
|
20 | if (mode === 'postinstall') {
|
21 | fsExists(sysPath.join(__dirname, 'lib'), function(exists) {
|
22 | if (exists) return;
|
23 | execute(['node_modules', 'coffee-script', 'bin', 'coffee'], '-o lib/ src/');
|
24 | });
|
25 | } else if (mode === 'test') {
|
26 | execute(['node_modules', 'mocha', 'bin', 'mocha'],
|
27 | '--require test/common.js --colors');
|
28 | }
|