-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
executable file
·65 lines (51 loc) · 1.91 KB
/
index.ts
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
'use strict';
//dts
import {ISumanOpts, ISumanConfig} from 'suman-types/dts/global';
//core
import assert = require('assert');
//project
import utils from './lib/utils';
import log from './lib/logging';
//////////////////////////////////////////////////////////////////////////////////////////////////
export interface ISumanWatchPerItem {
includes: string | Array<string>,
excludes: string | RegExp | Array<string | RegExp>,
include: string | Array<string>,
exclude: string | RegExp | Array<string | RegExp>,
exec: string,
confOverride: Partial<ISumanConfig>
}
///////////////////////////////////////////////////////////////////////////////////////////////////
export const runWatch = function (projectRoot: string, paths: Array<string>,
sumanConfig: ISumanConfig, sumanOpts: ISumanOpts, cb: Function) {
let callable = true;
let once = function(){
if(callable){
callable = false;
cb.apply(this,arguments);
}
};
let makeRun;
if (sumanOpts.watch_per) {
let {watchObj} = utils.getWatchObj(projectRoot, sumanOpts, sumanConfig);
if (watchObj.plugin) {
log.info('running "watch-per" * using suman-watch plugin *.');
makeRun = require('./lib/watch-per-with-plugin').makeRun;
}
else {
log.info('running "watch-per".');
makeRun = require('./lib/watch-per').makeRun;
}
}
else {
log.info('Running standard test script watcher.');
log.info('When changes are saved to a test script, that test script will be executed.');
makeRun = require('./lib/start-watching').makeRun;
}
assert(typeof makeRun === 'function',
'Suman implementation error - the desired suman-watch module does not export the expected interface.');
process.stdin.setEncoding('utf8').resume();
const run = makeRun(projectRoot, paths, sumanOpts);
run(sumanConfig, false, once);
};
export const plugins = require('suman-watch-plugins');