-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (39 loc) · 1.19 KB
/
index.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
#!/usr/bin/env node
'use strict';
const facilitator = require('./lib/facilitator');
const logger = require('./lib/logger');
const searcher = require('./lib/searcher');
const generator = require('./lib/generator');
const processor = require('./lib/processor');
const writer = require('./lib/writer');
facilitator.prepare();
const args = facilitator.facilitate();
const testDir = args.testDir;
const framework = args.framework;
const outputFile = args.output;
const isDryRun = args.dryRun;
const shouldSort = args.sort;
const shouldRandomise = args.randomize;
const quietMode = args.quiet;
const subDirToUseAsRoot = (
typeof (args.rootDir) === 'string'
) ? args.rootDir : testDir;
if (quietMode) {
logger.quiet = true;
}
module.exports = searcher.find(testDir, framework)
.then((results) => {
const output = generator.generate(
processor.process(testDir, results, subDirToUseAsRoot, shouldRandomise, shouldSort)
);
if (!isDryRun) {
writer.write(outputFile, output);
} else {
logger.warn('In dry run mode; file is *not* saved.');
}
})
.catch((err) => {
logger.error('ARGH! test-cat encountered an error and could not continue.');
logger.error(err);
}
);