Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const execPromise = promisify(exec);
interface Options {
cwd: PortablePath;
env?: Record<string, string>;
stdin?: string;
}

export type ExecResult = {
Expand All @@ -25,7 +26,7 @@ export const execFile = (
options: Options,
): Promise<ExecResult> => {
return new Promise((resolve, reject) => {
cp.execFile(path, args, {
const process = cp.execFile(path, args, {
...options,
cwd: options.cwd ? npath.fromPortablePath(options.cwd) : undefined,
}, (error, stdout, stderr) => {
Expand All @@ -50,6 +51,11 @@ export const execFile = (
});
}
});

if (typeof options.stdin !== `undefined`) {
process.stdin?.write(options.stdin);
process.stdin?.end();
}
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const mte = generatePkgDriver({
async runDriver(
path,
[command, ...args],
{cwd, execArgv = [], projectFolder, registryUrl, env, ...config},
{cwd, execArgv = [], projectFolder, registryUrl, env, stdin, ...config},
) {
const rcEnv: Record<string, any> = {};
for (const [key, value] of Object.entries(config))
Expand All @@ -32,6 +32,7 @@ const mte = generatePkgDriver({

const res = await execFile(process.execPath, [...execArgv, yarnBinary, ...cwdArgs, command, ...args], {
cwd: cwd || path,
stdin,
env: {
[`HOME`]: nativeHomePath,
[`USERPROFILE`]: nativeHomePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface RunDriverOptions extends Record<string, any> {
projectFolder?: PortablePath;
registryUrl: string;
env?: Record<string, string | undefined>;
stdin?: string;
}

export type PackageRunDriver = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@ describe(`Node_Modules`, () => {
},
});

await expect(run(`install`)).resolves.toMatchObject({code: 0});
await run(`install`);

await expect(xfs.readdirPromise(ppath.join(path, Filename.nodeModules))).resolves.toEqual([
`.yarn-state.yml`,
Expand Down
Loading