forked from sailshq/anchor
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrunner.js
More file actions
61 lines (56 loc) · 1.88 KB
/
runner.js
File metadata and controls
61 lines (56 loc) · 1.88 KB
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
var fs = require('fs');
var path = require('path');
var rimraf = require('rimraf');
var cp = require('child_process');
var download = require('download-git-repo');
var Mocha = require('mocha');
var mocha = new Mocha();
(function getTestFiles(dir) {
files = fs.readdirSync(dir);
files.forEach(function(file) {
if (fs.statSync(path.join(dir, file)).isDirectory()) {
return getTestFiles(path.join(dir, file));
}
mocha.addFile(path.join(dir, file));
});
})(__dirname);
mocha.run(function(failures) {
if (failures) {
process.on('exit', function() {
process.exit(failures);
});
} else {
download('Atlantis-Software/offshore', path.join(__dirname, '..', 'offshoreTest'), function (err) {
if (err) {
throw err;
}
var offshoreInstall = cp.exec('npm install', {
cwd: path.join(__dirname, '..', 'offshoreTest')
});
offshoreInstall.stderr.pipe(process.stderr);
offshoreInstall.stdout.pipe(process.stdout);
offshoreInstall.on('exit', function(code) {
rimraf(path.join(__dirname, '..', 'offshoreTest', 'node_modules', 'offshore-validator'), function(err) {
if (err) {
throw err;
}
fs.symlink(path.join(__dirname, '..'), path.join(__dirname, '..', 'offshoreTest', 'node_modules', 'offshore-validator'), function(err) {
if (err) {
throw err;
}
var offshoreTest = cp.exec('npm run test', {
cwd: path.join(__dirname, '..', 'offshoreTest')
});
offshoreTest.stderr.pipe(process.stderr);
offshoreTest.stdout.pipe(process.stdout);
offshoreTest.on('exit', function(code) {
rimraf(path.join(__dirname, '..', 'offshoreTest'), function(err) {
process.exit(code);
});
});
});
});
});
});
}
});