yarn.js 651 B

12345678910111213141516171819202122
  1. const cp = require('child_process');
  2. const fs = require('fs');
  3. const path = require('path');
  4. const YARN_VERSION = /'yarn_version': '(.+?)'/.exec(fs.readFileSync(path.resolve(__dirname, '../DEPS'), 'utf8'))[1];
  5. exports.YARN_VERSION = YARN_VERSION;
  6. // If we are running "node script/yarn" run as the yarn CLI
  7. if (process.mainModule === module) {
  8. const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx';
  9. const child = cp.spawn(NPX_CMD, [`yarn@${YARN_VERSION}`, ...process.argv.slice(2)], {
  10. stdio: 'inherit',
  11. env: {
  12. ...process.env,
  13. npm_config_yes: 'true'
  14. }
  15. });
  16. child.on('exit', code => process.exit(code));
  17. }