UNPKG

1.66 kBJavaScriptView Raw
1const vm = require ('vm');
2const fs = require ('fs');
3const path = require('path');
4
5var pkg = require('./package.json');
6
7// Gobble up a JSON file with comments
8function getJSON(filepath) {
9 const jsonString = "g = " + fs.readFileSync(filepath, 'utf8') + "; g";
10 return (new vm.Script(jsonString)).runInNewContext();
11}
12
13exports.default = function * (task) {
14 yield task.serial(['build']);
15}
16
17exports.clean = function * (task) {
18 yield task.clear(['lib-test', 'coverage']);
19}
20
21exports.superclean = function * (task) {
22 task.parallel(['clean']);
23 yield task.clear(['lib'])
24}
25
26exports.mrproper = function * (task) {
27 task.parallel(['superclean']);
28 yield task.clear(['node_modules'])
29}
30
31exports.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
42exports.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
52exports.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// exports.spec = function * (task) {
62// yield taskr.source("./test/**/*.jest.ts")
63// .shell({
64// cmd: 'jest --coverage $glob',
65// preferLocal: true,
66// glob: true
67// })
68// }
69
70
71exports.lint = function * (task) {
72 yield task.source('./{src,test}/**/*.ts')
73 .shell('tslint $glob')
74}