Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic authored and astrobot-houston committed Dec 5, 2024
1 parent 48ca399 commit 86abfa5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
40 changes: 20 additions & 20 deletions packages/astro/src/cli/info/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,36 +119,36 @@ export function readFromClipboard() {
let args: Array<string> = [];

if (system === 'darwin') {
command = 'pbpaste';
command = 'pbpaste';
} else if (system === 'win32') {
command = 'powershell';
args = ['-command', 'Get-Clipboard'];
command = 'powershell';
args = ['-command', 'Get-Clipboard'];
} else {
const unixCommands: Array<[string, Array<string>]> = [
['xclip', ['-sel', 'clipboard', '-o']],
['wl-paste', []],
];
for (const [unixCommand, unixArgs] of unixCommands) {
try {
const output = spawnSync('which', [unixCommand], { encoding: 'utf8' });
if (output.stdout.trim()) {
command = unixCommand;
args = unixArgs;
break;
}
} catch {
continue;
}
const unixCommands: Array<[string, Array<string>]> = [
['xclip', ['-sel', 'clipboard', '-o']],
['wl-paste', []],
];
for (const [unixCommand, unixArgs] of unixCommands) {
try {
const output = spawnSync('which', [unixCommand], { encoding: 'utf8' });
if (output.stdout.trim()) {
command = unixCommand;
args = unixArgs;
break;
}
} catch {
continue;
}
}
}

if (!command) {
throw new Error('Clipboard read command not found!');
throw new Error('Clipboard read command not found!');
}

const result = spawnSync(command, args, { encoding: 'utf8' });
if (result.error) {
throw result.error;
throw result.error;
}
return result.stdout.trim();
}
Expand Down
10 changes: 6 additions & 4 deletions packages/astro/test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import assert from 'node:assert/strict';
import { promises as fs, readFileSync } from 'node:fs';
import { isIPv4 } from 'node:net';
import { join } from 'node:path';
import { platform } from 'node:process';
import { Writable } from 'node:stream';
import { describe, it } from 'node:test';
import { fileURLToPath } from 'node:url';
import { stripVTControlCharacters } from 'node:util';
import { cli, cliServerLogSetup, loadFixture, parseCliDevStart } from './test-utils.js';
import { readFromClipboard } from '../dist/cli/info/index.js';
import { platform } from 'node:process';
import { cli, cliServerLogSetup, loadFixture, parseCliDevStart } from './test-utils.js';

describe('astro cli', () => {
const cliServerLogSetupWithFixture = (flags, cmd) => {
Expand Down Expand Up @@ -88,14 +88,16 @@ describe('astro cli', () => {
assert.equal(proc.exitCode, 0);

// On Linux we only check if we have Wayland or x11. In Codespaces it falsely reports that it does have x11
if(platform === 'linux' && ((!process.env.WAYLAND_DISPLAY && !process.env.DISPLAY) || process.env.CODESPACES)) {
if (
platform === 'linux' &&
((!process.env.WAYLAND_DISPLAY && !process.env.DISPLAY) || process.env.CODESPACES)
) {
assert.ok(proc.stdout.includes('Please manually copy the text above'));
} else {
assert.ok(proc.stdout.includes('Copied to clipboard!'));
const clipboardContent = await readFromClipboard();
assert.ok(clipboardContent.includes(`v${pkgVersion}`));
}

});

it(
Expand Down

0 comments on commit 86abfa5

Please sign in to comment.