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

fix(run): inherit stdio for running npm scripts #3881

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions libs/commands/run/src/index.ts
Expand Up @@ -7,7 +7,6 @@ import {
getPackage,
npmRunScript,
npmRunScriptStreaming,
output,
Package,
Profiler,
ProjectGraphProjectNodeWithPackage,
Expand Down Expand Up @@ -250,7 +249,6 @@ export class RunCommand extends Command<RunCommandConfigOptions> {
pkg.name,
(getElapsed() / 1000).toFixed(1)
);
output(result.stdout);

return result;
});
Expand Down
8 changes: 5 additions & 3 deletions libs/commands/run/src/lib/run-command.spec.ts
Expand Up @@ -45,9 +45,10 @@ const ranInPackagesStreaming = (testDir: string) =>
);

describe("RunCommand", () => {
npmRunScript.mockImplementation((script: string, { pkg }: { pkg: Package }) =>
Promise.resolve({ exitCode: 0, stdout: pkg.name })
);
npmRunScript.mockImplementation((script: string, { pkg }: { pkg: Package }) => {
output(pkg.name);
return Promise.resolve({ exitCode: 0, stdout: pkg.name });
});
npmRunScriptStreaming.mockImplementation(() => Promise.resolve({ exitCode: 0 }));

afterEach(() => {
Expand Down Expand Up @@ -166,6 +167,7 @@ describe("RunCommand", () => {
err.exitCode = 456;
err.stdout = pkg.name;

output(pkg.name);
return Promise.resolve(err);
});

Expand Down
5 changes: 5 additions & 0 deletions libs/core/src/lib/npm-run-script.spec.ts
Expand Up @@ -27,6 +27,7 @@ describe("npm-run-script", () => {
env: {},
pkg: config.pkg,
reject: true,
stdio: "inherit",
windowsHide: false,
});
});
Expand All @@ -49,6 +50,7 @@ describe("npm-run-script", () => {
env: {},
pkg: config.pkg,
reject: false,
stdio: "inherit",
windowsHide: false,
});
});
Expand All @@ -70,6 +72,7 @@ describe("npm-run-script", () => {
env: {},
pkg: config.pkg,
reject: true,
stdio: "inherit",
windowsHide: false,
});
});
Expand Down Expand Up @@ -100,6 +103,7 @@ describe("npm-run-script", () => {
},
pkg: config.pkg,
reject: true,
stdio: "inherit",
windowsHide: false,
},
config.pkg.name
Expand Down Expand Up @@ -130,6 +134,7 @@ describe("npm-run-script", () => {
},
pkg: config.pkg,
reject: false,
stdio: "inherit",
windowsHide: false,
},
undefined
Expand Down
1 change: 1 addition & 0 deletions libs/core/src/lib/npm-run-script.ts
Expand Up @@ -28,6 +28,7 @@ export function npmRunScriptStreaming(script: string, { args, npmClient, pkg, pr
function makeOpts(pkg: { name: any; location: string }, reject: any) {
return Object.assign(getNpmExecOpts(pkg), {
windowsHide: false,
stdio: "inherit" /*to support interactive prompts */,
reject,
});
}