From 316959355c3d59723ecb3e0f417becf1f03ddd74 Mon Sep 17 00:00:00 2001 From: Juraj Kapsz Date: Tue, 10 Dec 2024 13:43:44 +0100 Subject: [PATCH] fix: xclip process runtime (#12658) xclip process made `spawnSync` not [to return](https://nodejs.org/api/child_process.html#child_processspawnsynccommand-args-options:~:text=with%20the%20exception%20that%20the%20function%20will%20not%20return%20until%20the%20child%20process%20has%20fully%20closed). Further info at [Stack Overflow](https://stackoverflow.com/questions/52169670/node-child-process-execsync-hangs-with-xclip). Also updated the xclip arguments as per man pages for better familiarity, although the used arguments worked. --- .changeset/shy-worms-talk.md | 5 +++++ packages/astro/src/cli/info/index.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/shy-worms-talk.md diff --git a/.changeset/shy-worms-talk.md b/.changeset/shy-worms-talk.md new file mode 100644 index 0000000000..c22501e2d2 --- /dev/null +++ b/.changeset/shy-worms-talk.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes astro info copy to clipboard process not returning to prompt in certain cases. diff --git a/packages/astro/src/cli/info/index.ts b/packages/astro/src/cli/info/index.ts index 348d2fae3b..aca66ad719 100644 --- a/packages/astro/src/cli/info/index.ts +++ b/packages/astro/src/cli/info/index.ts @@ -66,7 +66,7 @@ export async function copyToClipboard(text: string, force?: boolean) { // Unix: check if a supported command is installed const unixCommands: Array<[string, Array]> = [ - ['xclip', ['-sel', 'clipboard', '-l', '1']], + ['xclip', ['-selection', 'clipboard', '-l', '1']], ['wl-copy', []], ]; for (const [unixCommand, unixArgs] of unixCommands) { @@ -101,7 +101,7 @@ export async function copyToClipboard(text: string, force?: boolean) { } try { - const result = spawnSync(command, args, { input: text }); + const result = spawnSync(command, args, { input: text, stdio: ['pipe', 'ignore', 'ignore'] }); if (result.error) { throw result.error; }