Skip to content

Commit

Permalink
Fix compatibility with yarn 1.22.0 (elastic#56917)
Browse files Browse the repository at this point in the history
* Revert "force yarn 1.21.1 until we can handle invalid output of 1.22.0 (elastic#56914)"

This reverts commit 5686010.

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

* update kbn/pm dist

(cherry picked from commit 12de6a8)
  • Loading branch information
Spencer authored and spalger committed Feb 5, 2020
1 parent e587166 commit 44727d0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 9 additions & 3 deletions packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56273,12 +56273,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}`);
}
}

/***/ }),
Expand Down
9 changes: 6 additions & 3 deletions packages/kbn-pm/src/utils/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
}

0 comments on commit 44727d0

Please sign in to comment.