react-native-navigation的迁移库

12345678910111213141516171819202122232425262728293031
  1. const exec = require('shell-utils').exec;
  2. const { includes, chain, split, filter } = 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 === 'e2e' ? `${d}/**/*.[tj]s` : `${d}/**/*.[tj]sx?`).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. }