mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
[ci] format
This commit is contained in:
parent
48ca399788
commit
86abfa5c81
2 changed files with 26 additions and 24 deletions
|
@ -119,36 +119,36 @@ export function readFromClipboard() {
|
||||||
let args: Array<string> = [];
|
let args: Array<string> = [];
|
||||||
|
|
||||||
if (system === 'darwin') {
|
if (system === 'darwin') {
|
||||||
command = 'pbpaste';
|
command = 'pbpaste';
|
||||||
} else if (system === 'win32') {
|
} else if (system === 'win32') {
|
||||||
command = 'powershell';
|
command = 'powershell';
|
||||||
args = ['-command', 'Get-Clipboard'];
|
args = ['-command', 'Get-Clipboard'];
|
||||||
} else {
|
} else {
|
||||||
const unixCommands: Array<[string, Array<string>]> = [
|
const unixCommands: Array<[string, Array<string>]> = [
|
||||||
['xclip', ['-sel', 'clipboard', '-o']],
|
['xclip', ['-sel', 'clipboard', '-o']],
|
||||||
['wl-paste', []],
|
['wl-paste', []],
|
||||||
];
|
];
|
||||||
for (const [unixCommand, unixArgs] of unixCommands) {
|
for (const [unixCommand, unixArgs] of unixCommands) {
|
||||||
try {
|
try {
|
||||||
const output = spawnSync('which', [unixCommand], { encoding: 'utf8' });
|
const output = spawnSync('which', [unixCommand], { encoding: 'utf8' });
|
||||||
if (output.stdout.trim()) {
|
if (output.stdout.trim()) {
|
||||||
command = unixCommand;
|
command = unixCommand;
|
||||||
args = unixArgs;
|
args = unixArgs;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!command) {
|
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' });
|
const result = spawnSync(command, args, { encoding: 'utf8' });
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
throw result.error;
|
throw result.error;
|
||||||
}
|
}
|
||||||
return result.stdout.trim();
|
return result.stdout.trim();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,13 @@ import assert from 'node:assert/strict';
|
||||||
import { promises as fs, readFileSync } from 'node:fs';
|
import { promises as fs, readFileSync } from 'node:fs';
|
||||||
import { isIPv4 } from 'node:net';
|
import { isIPv4 } from 'node:net';
|
||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
|
import { platform } from 'node:process';
|
||||||
import { Writable } from 'node:stream';
|
import { Writable } from 'node:stream';
|
||||||
import { describe, it } from 'node:test';
|
import { describe, it } from 'node:test';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import { stripVTControlCharacters } from 'node:util';
|
import { stripVTControlCharacters } from 'node:util';
|
||||||
import { cli, cliServerLogSetup, loadFixture, parseCliDevStart } from './test-utils.js';
|
|
||||||
import { readFromClipboard } from '../dist/cli/info/index.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', () => {
|
describe('astro cli', () => {
|
||||||
const cliServerLogSetupWithFixture = (flags, cmd) => {
|
const cliServerLogSetupWithFixture = (flags, cmd) => {
|
||||||
|
@ -88,14 +88,16 @@ describe('astro cli', () => {
|
||||||
assert.equal(proc.exitCode, 0);
|
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
|
// 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'));
|
assert.ok(proc.stdout.includes('Please manually copy the text above'));
|
||||||
} else {
|
} else {
|
||||||
assert.ok(proc.stdout.includes('Copied to clipboard!'));
|
assert.ok(proc.stdout.includes('Copied to clipboard!'));
|
||||||
const clipboardContent = await readFromClipboard();
|
const clipboardContent = await readFromClipboard();
|
||||||
assert.ok(clipboardContent.includes(`v${pkgVersion}`));
|
assert.ok(clipboardContent.includes(`v${pkgVersion}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it(
|
it(
|
||||||
|
|
Loading…
Reference in a new issue