unit.js 1006 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const path = require('path');
  2. const { spawnSync } = require('child_process');
  3. const packages = [
  4. 'babel-plugin-import-regenerator',
  5. 'cli',
  6. //'compiler-babel',
  7. 'compiler-less',
  8. 'compiler-sass',
  9. //'compiler-stylus',
  10. //'compiler-typescript',
  11. 'core',
  12. 'plugin-define',
  13. //'plugin-eslint',
  14. //'plugin-uglifyjs',
  15. //'redux',
  16. 'use-intercept',
  17. 'use-promisify'
  18. //'x',
  19. ];
  20. function testAll(pkgs) {
  21. if (pkgs.length === 0) {
  22. pkgs = packages;
  23. }
  24. pkgs.forEach(pkg => {
  25. testOne(pkg);
  26. });
  27. }
  28. function testOne(name) {
  29. process.env.FORCE_COLOR = 1;
  30. const command = process.platform === 'win32' ? 'npm.cmd' : 'npm';
  31. const result = spawnSync(command, ['run', 'test'], {
  32. cwd: path.join(process.cwd(), 'packages', name),
  33. env: process.env,
  34. stdio: 'inherit'
  35. });
  36. if (result.status !== 0) {
  37. throw new Error('Test cases failed in: ' + name);
  38. }
  39. }
  40. // eslint-disable-next-line no-unused-vars
  41. (function main([bin, file, ...args]) {
  42. testAll(args);
  43. })(process.argv);