-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
45 lines (30 loc) · 1.28 KB
/
Gruntfile.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
module.exports = function (grunt) {
const buildTsc = project => new Promise((resolve, reject) => {
const args = ['-p', project, '--listEmittedFiles'];
grunt.log.writeln(`tsc ${args.join(' ')} : ${new Date()}`);
//try { require('fs').unlinkSync('./dist/ajst.d.ts'); } catch (e) { } // for recreate
grunt.util.spawn({
cmd: 'tsc',
args,
opts: { stdio: [process.stdin, process.stdout, process.stderr] }
}, err => resolve(err));
});
grunt.registerTask('ajst:build', 'Typescript Build', async function () {
require('time-grunt')(grunt);
const project = '.';
const done = this.async();
const err = await buildTsc(project);
err && grunt.log.error(err);
await buildTsc('./tsconfig.commonjs.json');
done(err ? false : true);
});
grunt.registerTask('ajst:watch', 'Typescript Build Watch', function () {
const project = '.';
const execute = () => buildTsc(project);
const watchGlob = require('watch-glob');
const done = this.async();
execute(); // init build
watchGlob(['tsconfig.json', 'ajst.ts', 'ajst/**/*.ts'], { delay: 100 }, execute, execute);
});
grunt.registerTask("default", ["ajst:build"]);
};