Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. let fs;
  2. let globby;
  3.  
  4. try {
  5. fs = require('fs-extra');
  6. globby = require('globby');
  7. } catch (error) {
  8. console.log(
  9. 'Could not load required modules. Please run `npm install` and run again.',
  10. );
  11. console.log(error.stack);
  12. console.log();
  13.  
  14. process.exit(1);
  15. }
  16.  
  17. const moveFile = (from, to) => {
  18. console.log(`Moving: ${from} -> ${to}`);
  19. fs.moveSync(from, to);
  20. };
  21.  
  22. try {
  23. const e2eTestFilePaths = globby.sync('test/{e2e,server}/**/*.spec.[j|t]s', {
  24. dot: true,
  25. gitignore: true,
  26. });
  27.  
  28. // We removed the `server` environment, these tests are now e2e
  29. e2eTestFilePaths.map(file => moveFile(file, file.replace('.spec.', '.e2e.')));
  30.  
  31. // Move JS setup files to new format
  32. if (fs.pathExistsSync('test/setup.e2e.js')) {
  33. moveFile('test/setup.e2e.js', 'test/e2e-setup.js');
  34. }
  35.  
  36. if (fs.pathExistsSync('test/setup.component.js')) {
  37. moveFile('test/setup.component.js', 'test/spec-setup.js');
  38. }
  39.  
  40. // Move TS setup files to new format
  41. if (fs.pathExistsSync('test/setup.e2e.ts')) {
  42. moveFile('test/setup.e2e.ts', 'test/e2e-setup.ts');
  43. }
  44.  
  45. if (fs.pathExistsSync('test/setup.component.ts')) {
  46. moveFile('test/setup.component.ts', 'test/spec-setup.ts');
  47. }
  48.  
  49. // Warn if a server setup script exist: it should be merged with the one from e2e tests
  50. if (
  51. fs.pathExistsSync('test/setup.server.js') ||
  52. fs.pathExistsSync('test/setup.server.ts')
  53. ) {
  54. console.log(
  55. 'You have a "test/setup.server.[j|t]s" in your project. Please remove it and move its content to "test/e2e-setup.[j|t]s"',
  56. );
  57. }
  58. } catch (error) {
  59. console.log('Failed migrating project.');
  60. console.log(error.stack);
  61. console.log();
  62.  
  63. process.exit(1);
  64. }
  65.  
  66. console.log('Project migrated successfully.');
  67. console.log();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement