Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Prefer using npm_execpath when spawning Yarn (#68673) #68696

Merged
merged 1 commit into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55324,6 +55324,7 @@ __webpack_require__.r(__webpack_exports__);
* under the License.
*/

const YARN_EXEC = process.env.npm_execpath || 'yarn';

/**
* Install all dependencies in the given directory
Expand All @@ -55332,7 +55333,7 @@ async function installInDir(directory, extraArgs = []) {
const options = ['install', '--non-interactive', ...extraArgs]; // We pass the mutex flag to ensure only one instance of yarn runs at any
// given time (e.g. to avoid conflicts).

await Object(_child_process__WEBPACK_IMPORTED_MODULE_0__["spawn"])('yarn', options, {
await Object(_child_process__WEBPACK_IMPORTED_MODULE_0__["spawn"])(YARN_EXEC, options, {
cwd: directory
});
}
Expand All @@ -55344,7 +55345,7 @@ async function runScriptInPackage(script, args, pkg) {
const execOpts = {
cwd: pkg.path
};
await Object(_child_process__WEBPACK_IMPORTED_MODULE_0__["spawn"])('yarn', ['run', script, ...args], execOpts);
await Object(_child_process__WEBPACK_IMPORTED_MODULE_0__["spawn"])(YARN_EXEC, ['run', script, ...args], execOpts);
}
/**
* Run script in the given directory
Expand All @@ -55359,15 +55360,15 @@ function runScriptInPackageStreaming({
const execOpts = {
cwd: pkg.path
};
return Object(_child_process__WEBPACK_IMPORTED_MODULE_0__["spawnStreaming"])('yarn', ['run', script, ...args], execOpts, {
return Object(_child_process__WEBPACK_IMPORTED_MODULE_0__["spawnStreaming"])(YARN_EXEC, ['run', script, ...args], execOpts, {
prefix: pkg.name,
debug
});
}
async function yarnWorkspacesInfo(directory) {
const {
stdout
} = await Object(_child_process__WEBPACK_IMPORTED_MODULE_0__["spawn"])('yarn', ['--json', 'workspaces', 'info'], {
} = await Object(_child_process__WEBPACK_IMPORTED_MODULE_0__["spawn"])(YARN_EXEC, ['--json', 'workspaces', 'info'], {
cwd: directory,
stdio: 'pipe'
});
Expand Down
10 changes: 6 additions & 4 deletions packages/kbn-pm/src/utils/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import { spawn, spawnStreaming } from './child_process';
import { Project } from './project';

const YARN_EXEC = process.env.npm_execpath || 'yarn';

interface WorkspaceInfo {
location: string;
workspaceDependencies: string[];
Expand All @@ -37,7 +39,7 @@ export async function installInDir(directory: string, extraArgs: string[] = [])

// We pass the mutex flag to ensure only one instance of yarn runs at any
// given time (e.g. to avoid conflicts).
await spawn('yarn', options, {
await spawn(YARN_EXEC, options, {
cwd: directory,
});
}
Expand All @@ -50,7 +52,7 @@ export async function runScriptInPackage(script: string, args: string[], pkg: Pr
cwd: pkg.path,
};

await spawn('yarn', ['run', script, ...args], execOpts);
await spawn(YARN_EXEC, ['run', script, ...args], execOpts);
}

/**
Expand All @@ -71,14 +73,14 @@ export function runScriptInPackageStreaming({
cwd: pkg.path,
};

return spawnStreaming('yarn', ['run', script, ...args], execOpts, {
return spawnStreaming(YARN_EXEC, ['run', script, ...args], execOpts, {
prefix: pkg.name,
debug,
});
}

export async function yarnWorkspacesInfo(directory: string): Promise<WorkspacesInfo> {
const { stdout } = await spawn('yarn', ['--json', 'workspaces', 'info'], {
const { stdout } = await spawn(YARN_EXEC, ['--json', 'workspaces', 'info'], {
cwd: directory,
stdio: 'pipe',
});
Expand Down