0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

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.
This commit is contained in:
Juraj Kapsz 2024-12-10 13:43:44 +01:00 committed by GitHub
parent 0d1eab560d
commit 316959355c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fixes astro info copy to clipboard process not returning to prompt in certain cases.

View file

@ -66,7 +66,7 @@ export async function copyToClipboard(text: string, force?: boolean) {
// Unix: check if a supported command is installed // Unix: check if a supported command is installed
const unixCommands: Array<[string, Array<string>]> = [ const unixCommands: Array<[string, Array<string>]> = [
['xclip', ['-sel', 'clipboard', '-l', '1']], ['xclip', ['-selection', 'clipboard', '-l', '1']],
['wl-copy', []], ['wl-copy', []],
]; ];
for (const [unixCommand, unixArgs] of unixCommands) { for (const [unixCommand, unixArgs] of unixCommands) {
@ -101,7 +101,7 @@ export async function copyToClipboard(text: string, force?: boolean) {
} }
try { try {
const result = spawnSync(command, args, { input: text }); const result = spawnSync(command, args, { input: text, stdio: ['pipe', 'ignore', 'ignore'] });
if (result.error) { if (result.error) {
throw result.error; throw result.error;
} }