yarn.js 638 B

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