react-native-navigation的迁移库

test-js.js 835B

1234567891011121314151617181920212223242526272829303132
  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. exec.execSync('node -v');
  14. const paths = _.chain(dirs).map((d) => `'${d}/**/*.[tj]s*'`).join(' ').value();
  15. exec.execSync(`tslint ${paths} ${fix} --format verbose`);
  16. assertAllTsFilesInSrc();
  17. exec.execSync(`jest --coverage`);
  18. }
  19. function assertAllTsFilesInSrc() {
  20. const allFiles = exec.execSyncRead('find ./lib/src -type f');
  21. const lines = _.split(allFiles, '\n');
  22. const offenders = _.filter(lines, (f) => !f.endsWith('.ts') && !f.endsWith('.tsx'));
  23. if (offenders.length) {
  24. throw new Error(`\n\nOnly ts/tsx files are allowed:\n${offenders.join('\n')}\n\n\n`);
  25. }
  26. }