react-native-navigation的迁移库

test-js.js 807B

12345678910111213141516171819202122232425262728293031
  1. const exec = require('shell-utils').exec;
  2. const _ = require('lodash');
  3. const fix = _.includes(process.argv, '--fix') ? '--fix' : '';
  4. const dirs = [
  5. 'lib/src',
  6. 'integration',
  7. 'e2e',
  8. 'scripts',
  9. 'playground/src'
  10. ];
  11. run();
  12. function run() {
  13. const paths = _.chain(dirs).map((d) => `'${d}/**/*.[tj]s*'`).join(' ').value();
  14. exec.execSync(`tslint ${paths} ${fix} --format verbose`);
  15. assertAllTsFilesInSrc();
  16. exec.execSync(`jest --coverage`);
  17. }
  18. function assertAllTsFilesInSrc() {
  19. const allFiles = exec.execSyncRead('find ./lib/src -type f');
  20. const lines = _.split(allFiles, '\n');
  21. const offenders = _.filter(lines, (f) => !f.endsWith('.ts') && !f.endsWith('.tsx'));
  22. if (offenders.length) {
  23. throw new Error(`\n\nOnly ts/tsx files are allowed:\n${offenders.join('\n')}\n\n\n`);
  24. }
  25. }