unit.js 936 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 result = spawnSync('npm', ['run', 'test'], {
  31. cwd: path.join(process.cwd(), 'packages', name),
  32. env: process.env,
  33. stdio: 'inherit'
  34. });
  35. if (result.status !== 0) {
  36. throw new Error('Test cases failed in: ' + name);
  37. }
  38. }
  39. // eslint-disable-next-line no-unused-vars
  40. (function main([bin, file, ...args]) {
  41. testAll(args);
  42. })(process.argv);