forked from wix/react-native-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-js.js
30 lines (25 loc) · 840 Bytes
/
test-js.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
const exec = require('shell-utils').exec;
const _ = require('lodash');
const fix = _.includes(process.argv, '--fix') ? '--fix' : '';
const dirs = [
'lib/src',
'integration',
'e2e',
'scripts',
'playground/src'
];
run();
function run() {
const paths = _.chain(dirs).map((d) => d === 'e2e' ? `${d}/**/*.[tj]s` : `${d}/**/*.[tj]sx?`).join(' ').value();
exec.execSync(`tslint ${paths} ${fix} --format verbose`);
assertAllTsFilesInSrc();
exec.execSync(`jest --coverage`);
}
function assertAllTsFilesInSrc() {
const allFiles = exec.execSyncRead('find ./lib/src -type f');
const lines = _.split(allFiles, '\n');
const offenders = _.filter(lines, (f) => !f.endsWith('.ts') && !f.endsWith('.tsx'));
if (offenders.length) {
throw new Error(`\n\nOnly ts/tsx files are allowed:\n${offenders.join('\n')}\n\n\n`);
}
}