yarn.js 574 B

123456789101112131415161718
  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. })
  12. child.on('exit', code => process.exit(code))
  13. }