Skip to content

Commit 00506b2

Browse files
authored
fix: group the download prompt together (#391)
1 parent 476b7dc commit 00506b2

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

sources/httpUtils.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,19 @@ export async function fetchAsJson(input: string | URL, init?: RequestInit) {
4040

4141
export async function fetchUrlStream(input: string | URL, init?: RequestInit) {
4242
if (process.env.COREPACK_ENABLE_DOWNLOAD_PROMPT === `1`) {
43-
console.error(`Corepack is about to download ${input}.`);
43+
console.error(`Corepack is about to download ${input}`);
4444
if (stdin.isTTY && !process.env.CI) {
45-
stderr.write(`\nDo you want to continue? [Y/n] `);
45+
stderr.write(`Do you want to continue? [Y/n] `);
4646
stdin.resume();
4747
const chars = await once(stdin, `data`);
4848
stdin.pause();
49-
if (
50-
chars[0][0] === 0x6e || // n
51-
chars[0][0] === 0x4e // N
52-
) {
49+
50+
// n / N
51+
if (chars[0][0] === 0x6e || chars[0][0] === 0x4e)
5352
throw new UsageError(`Aborted by the user`);
54-
}
53+
54+
// Add a newline to separate Corepack output from the package manager
55+
console.error();
5556
}
5657
}
5758

tests/main.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ it(`should show a warning on stderr before downloading when enable`, async() =>
735735
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
736736
exitCode: 0,
737737
stdout: `3.0.0\n`,
738-
stderr: `Corepack is about to download https://repo.yarnpkg.com/3.0.0/packages/yarnpkg-cli/bin/yarn.js.\n`,
738+
stderr: `Corepack is about to download https://repo.yarnpkg.com/3.0.0/packages/yarnpkg-cli/bin/yarn.js\n`,
739739
});
740740
});
741741
});

0 commit comments

Comments
 (0)