bootstrap.js 769 B

1234567891011121314151617181920212223242526272829
  1. const os = require('os');
  2. const path = require('path');
  3. const child_process = require('child_process');
  4. const root = path.resolve(__dirname, '..');
  5. const args = process.argv.slice(2);
  6. const options = {
  7. cwd: process.cwd(),
  8. env: process.env,
  9. stdio: 'inherit',
  10. encoding: 'utf-8',
  11. };
  12. if (os.type() === 'Windows_NT') {
  13. options.shell = true;
  14. }
  15. let result;
  16. if (process.cwd() !== root || args.length) {
  17. // We're not in the root of the project, or additional arguments were passed
  18. // In this case, forward the command to `yarn`
  19. result = child_process.spawnSync('yarn', args, options);
  20. } else {
  21. // If `yarn` is run without arguments, perform bootstrap
  22. result = child_process.spawnSync('yarn', ['bootstrap'], options);
  23. }
  24. process.exitCode = result.status;