0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-03-10 23:01:26 -05:00

fix: Astro info throws when xclip is not available (#9042)

* Update index.ts

* Create hot-teachers-wave.md

* Update .changeset/hot-teachers-wave.md

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>

---------

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
This commit is contained in:
Rishi Raj Jain 2023-11-10 18:58:47 +05:30 committed by GitHub
parent 49b82edb2c
commit 7dedd17fc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Safely bail when the `xclip` command does not exist on Linux when trying to copy to clipboard with `astro info`

View file

@ -49,13 +49,19 @@ async function copyToClipboard(text: string) {
} else if (system === 'win32') {
command = 'clip';
} else {
// Unix: check if `xclip` is installed
const output = execSync('which xclip', { encoding: 'utf8' });
if (output[0] !== '/') {
// Did not find a path for xclip, bail out!
return;
try {
// Unix: check if `xclip` is installed
const output = execSync('which xclip', { encoding: 'utf8' });
if (output[0] !== '/') {
// Did not find a path for xclip, bail out!
return;
}
command = 'xclip -sel clipboard -l 1';
}
catch (e) {
// Did not find xclip, bail out!
return
}
command = 'xclip -sel clipboard -l 1';
}
console.log();