react-native-navigation的迁移库

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