Fix compatibility with yarn 1.22.0 (#56917)

* Revert "force yarn 1.21.1 until we can handle invalid output of 1.22.0 (#56914)"

This reverts commit 5686010b46.

* move the --json argument before `workspaces` so it still works

* update kbn/pm dist
This commit is contained in:
Spencer 2020-02-05 14:18:10 -07:00 committed by GitHub
parent 7276087e8a
commit 12de6a8459
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 9 deletions

View file

@ -486,6 +486,6 @@
},
"engines": {
"node": "10.18.0",
"yarn": "1.21.1"
"yarn": "^1.21.1"
}
}

View file

@ -56572,12 +56572,18 @@ function runScriptInPackageStreaming(script, args, pkg) {
});
}
async function yarnWorkspacesInfo(directory) {
const workspacesInfo = await Object(_child_process__WEBPACK_IMPORTED_MODULE_0__["spawn"])('yarn', ['workspaces', 'info', '--json'], {
const {
stdout
} = await Object(_child_process__WEBPACK_IMPORTED_MODULE_0__["spawn"])('yarn', ['--json', 'workspaces', 'info'], {
cwd: directory,
stdio: 'pipe'
});
const stdout = JSON.parse(workspacesInfo.stdout);
return JSON.parse(stdout.data);
try {
return JSON.parse(JSON.parse(stdout).data);
} catch (error) {
throw new Error(`'yarn workspaces info --json' produced unexpected output: \n${stdout}`);
}
}
/***/ }),

View file

@ -67,11 +67,14 @@ export function runScriptInPackageStreaming(script: string, args: string[], pkg:
}
export async function yarnWorkspacesInfo(directory: string): Promise<WorkspacesInfo> {
const workspacesInfo = await spawn('yarn', ['workspaces', 'info', '--json'], {
const { stdout } = await spawn('yarn', ['--json', 'workspaces', 'info'], {
cwd: directory,
stdio: 'pipe',
});
const stdout = JSON.parse(workspacesInfo.stdout);
return JSON.parse(stdout.data);
try {
return JSON.parse(JSON.parse(stdout).data);
} catch (error) {
throw new Error(`'yarn workspaces info --json' produced unexpected output: \n${stdout}`);
}
}

View file

@ -108,7 +108,8 @@ if [[ "$installNode" == "true" || ! $(which yarn) ]]; then
###
### downloading yarn
###
npm install -g "yarn@$(node -e "console.log(require('./package.json').engines.yarn)")"
yarnVersion="$(node -e "console.log(String(require('./package.json').engines.yarn || '').replace(/^[^\d]+/,''))")"
npm install -g "yarn@^${yarnVersion}"
fi
###

View file

@ -351,7 +351,7 @@
"xregexp": "4.2.4"
},
"engines": {
"yarn": "1.21.1"
"yarn": "^1.21.1"
},
"workspaces": {
"nohoist": [