build: unify YARN_VERSION variable usage and ensure CI uses yarn not npm (#18607)

* build: unify YARN_VERSION variable usage and ensure CI uses yarn not npm

* chore: use a JS helper so that it can work on windows

* chore: make script/yarn without node_modules installed
This commit is contained in:
Samuel Attard 2019-06-05 16:30:39 -07:00 committed by GitHub
parent 0fc172fcaf
commit a45afddb75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 18 deletions

View file

@ -1,11 +1,9 @@
// KEEP IN SYNC WITH DEPS FILE
const YARN_VERSION = '1.15.2'
const { GitProcess } = require('dugite')
const fs = require('fs')
const path = require('path')
const OUT_DIR = process.env.ELECTRON_OUT_DIR || 'Debug'
const { GitProcess } = require('dugite')
const path = require('path')
require('colors')
const pass = '\u2713'.green
const fail = '\u2717'.red
@ -45,6 +43,5 @@ module.exports = {
getCurrentBranch,
getElectronExec,
getAbsoluteElectronExec,
OUT_DIR,
YARN_VERSION
OUT_DIR
}

View file

@ -7,6 +7,7 @@ const NAN_DIR = path.resolve(BASE, 'third_party', 'nan')
const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'
const utils = require('./lib/utils')
const { YARN_VERSION } = require('./yarn')
if (!process.mainModule) {
throw new Error('Must call the nan spec runner directly')
@ -29,7 +30,7 @@ async function main () {
return process.exit(buildStatus)
}
const { status: installStatus } = cp.spawnSync(NPX_CMD, [`yarn@${utils.YARN_VERSION}`, 'install'], {
const { status: installStatus } = cp.spawnSync(NPX_CMD, [`yarn@${YARN_VERSION}`, 'install'], {
env,
cwd: NAN_DIR,
stdio: 'inherit'

View file

@ -22,6 +22,7 @@ for (const flag of unknownFlags) {
}
const utils = require('./lib/utils')
const { YARN_VERSION } = require('./yarn')
const BASE = path.resolve(__dirname, '../..')
const NPM_CMD = process.platform === 'win32' ? 'npm.cmd' : 'npm'
@ -144,7 +145,7 @@ async function installSpecModules () {
npm_config_nodedir: nodeDir,
npm_config_msvs_version: '2017'
})
const { status } = childProcess.spawnSync(NPX_CMD, [`yarn@${utils.YARN_VERSION}`, 'install', '--frozen-lockfile'], {
const { status } = childProcess.spawnSync(NPX_CMD, [`yarn@${YARN_VERSION}`, 'install', '--frozen-lockfile'], {
env,
cwd: path.resolve(__dirname, '../spec'),
stdio: 'inherit'

18
script/yarn.js Normal file
View file

@ -0,0 +1,18 @@
const cp = require('child_process')
const fs = require('fs')
const path = require('path')
const YARN_VERSION = /'yarn_version': '(.+?)'/.exec(fs.readFileSync(path.resolve(__dirname, '../DEPS'), 'utf8'))[1]
exports.YARN_VERSION = YARN_VERSION
// If we are running "node script/yarn" run as the yarn CLI
if (process.mainModule === module) {
const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'
const child = cp.spawn(NPX_CMD, [`yarn@${YARN_VERSION}`, ...process.argv.slice(2)], {
stdio: 'inherit'
})
child.on('exit', code => process.exit(code))
}