1 | const vm = require ('vm');
|
2 | const fs = require ('fs');
|
3 | const path = require('path');
|
4 |
|
5 | var pkg = require('./package.json');
|
6 |
|
7 |
|
8 | function getJSON(filepath) {
|
9 | const jsonString = "g = " + fs.readFileSync(filepath, 'utf8') + "; g";
|
10 | return (new vm.Script(jsonString)).runInNewContext();
|
11 | }
|
12 |
|
13 | exports.default = function * (task) {
|
14 | yield task.serial(['build']);
|
15 | }
|
16 |
|
17 | exports.clean = function * (task) {
|
18 | yield task.clear(['lib-test', 'coverage']);
|
19 | }
|
20 |
|
21 | exports.superclean = function * (task) {
|
22 | task.parallel(['clean']);
|
23 | yield task.clear(['lib'])
|
24 | }
|
25 |
|
26 | exports.mrproper = function * (task) {
|
27 | task.parallel(['superclean']);
|
28 | yield task.clear(['node_modules'])
|
29 | }
|
30 |
|
31 | exports.build = function * (task) {
|
32 | let tsopts = getJSON('./tsconfig.json')
|
33 | ;
|
34 |
|
35 | yield task.source('src/**/*.ts')
|
36 | .typescript(tsopts)
|
37 | .target('lib')
|
38 | .source('bin/**/*')
|
39 | .target('./lib', { mode: 0o775 })
|
40 | }
|
41 |
|
42 | exports.buildtest = function * (task) {
|
43 | let tsopts = getJSON('./tsconfig.json')
|
44 | ;
|
45 |
|
46 | yield task.serial(['build'])
|
47 | .source("test/**/*.ts")
|
48 | .typescript(tsopts)
|
49 | .target("lib-test/test")
|
50 | }
|
51 |
|
52 | exports.test = function * (task) {
|
53 | yield task.serial(['buildtest'])
|
54 | .source("./lib-test/test/**/*.test.js")
|
55 | .shell({
|
56 | cmd: 'mocha -u tdd --colors $glob',
|
57 | preferLocal: true,
|
58 | glob: true
|
59 | })
|
60 | }
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | exports.lint = function * (task) {
|
72 | yield task.source('./{src,test}/**/*.ts')
|
73 | .shell('tslint $glob')
|
74 | }
|