-
Notifications
You must be signed in to change notification settings - Fork 231
/
make.js
86 lines (69 loc) · 1.83 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
require('shelljs/make');
var path = require('path');
var fs = require('fs');
var semver = require('semver');
var rp = function(relPath) {
return path.join(__dirname, relPath);
}
var buildPath = path.join(__dirname, '_build');
var run = function(cl) {
console.log('> ' + cl);
var rc = exec(cl).code;
if (rc !== 0) {
echo('Exec failed with rc ' + rc);
exit(rc);
}
}
target.clean = function() {
rm('-Rf', buildPath);
};
target.build = function() {
target.clean();
run('tsc --outDir ' + buildPath);
cp('-Rf', rp('api/opensource'), buildPath);
cp(rp('LICENSE'), buildPath);
cp(rp('package.json'), buildPath);
cp(rp('package-lock.json'), buildPath);
cp(rp('ThirdPartyNotice.txt'), buildPath);
cp(rp('README.md'), buildPath);
// just a bootstrap file to avoid /// in final js and .d.ts file
rm(path.join(buildPath, 'index.*'));
}
target.units = function() {
target.build();
var nodeVer = process.versions.node;
//check for node version, since installation strategy is different for node versions less than 8
if(semver.lt(nodeVer,'8.0.0')){
pushd('_build');
}
else{
pushd('test');
}
run('npm install ../_build');
popd();
console.log("-------Unit Tests-------");
run('tsc -p ./test/units');
run('mocha test/units');
}
target.test = function() {
target.units();
}
target.samples = function() {
target.build();
var modPath = path.join(__dirname, 'samples', 'node_modules');
rm('-Rf', modPath);
mkdir('-p', modPath);
pushd('samples');
run('npm install ../_build');
popd();
run('tsc -p samples');
pushd('samples');
if (process.argv[3]) {
run('node run.js ' + process.argv[3]);
}
else {
run('node run.js');
}
popd();
console.log('done');
}