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:
parent
49b82edb2c
commit
7dedd17fc4
2 changed files with 17 additions and 6 deletions
5
.changeset/hot-teachers-wave.md
Normal file
5
.changeset/hot-teachers-wave.md
Normal 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`
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue