-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.js
44 lines (35 loc) · 999 Bytes
/
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
require('shelljs/make');
const path = require('path');
const os = require("os");
const isWin32 = os.platform() === "win32";
const rp = function (relPath) {
return path.join(__dirname, relPath);
};
const safePath = function(path){
if (isWin32 && path.match(/\s/)) path = '"' + path + '"';
return path;
};
const buildPath = path.join(__dirname, 'dist');
const run = function (cl) {
try {
console.log('> ' + cl);
const rc = exec(cl).code;
if (rc !== 0) {
echo('Exec failed with rc ' + rc);
exit(rc);
}
} catch (err) {
echo(err.message);
exit(1);
}
};
target.clean = function () {
rm('-Rf', buildPath);
};
target.build = function () {
run(safePath(path.join(__dirname, 'node_modules/.bin/tsc')) + ' --outDir ' + safePath(buildPath));
cp(rp('LICENSE'), buildPath);
cp(rp('package.json'), buildPath);
cp(rp('package-lock.json'), buildPath);
cp(rp('README.md'), buildPath);
};