forked from wix/react-native-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-js.js
32 lines (27 loc) · 1.05 KB
/
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
31
32
const exec = require('shell-utils').exec;
const includes = require('lodash/includes');
const split = require('lodash/split');
const filter = require('lodash/filter');
const fix = includes(process.argv, '--fix') ? '--fix' : '';
/**
* Temporarily disabling lint checking until the lint/prettier settings are settled.
*
* @todo Uncomment the following and run auto lint fix on these.
* @author Jin Shin (22/06/2020)
*/
// const dirs = ['lib/src', 'integration', 'scripts', 'playground/src'].join(' ');
const dirs = [];
run();
function run() {
exec.execSync(`eslint ${dirs} ${fix} --ext .js,.jsx,.ts,.tsx --format "codeframe"`);
assertAllTsFilesInSrc();
exec.execSync(`jest --coverage --config ./jest.config.js`);
}
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`);
}
}