项目文件夹

文件
wehub-resource-sync 2771cff92b
CI / lint (push) Failing after 1s
CI / typecheck (push) Failing after 2s
CI / test (push) Failing after 1s
CI / build (push) Has been skipped
chore: import upstream snapshot with attribution
2026-07-13 12:22:56 +08:00

34 行
939 B
TypeScript

import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import { findCliBinaryPath, resolveConfiguredCliPath } from '@/utils/cliBinaryLocator';
describe('cliBinaryLocator', () => {
let tempDir: string;
beforeEach(() => {
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'cli-binary-locator-'));
});
afterEach(() => {
fs.rmSync(tempDir, { recursive: true, force: true });
});
it('resolves configured CLI files', () => {
const cliPath = path.join(tempDir, 'pi');
fs.writeFileSync(cliPath, '');
expect(resolveConfiguredCliPath(cliPath)).toBe(cliPath);
});
it('finds Windows npm .cmd shims on a PATH entry', () => {
const binDir = path.join(tempDir, 'bin');
const shimPath = path.join(binDir, 'pi.cmd');
fs.mkdirSync(binDir, { recursive: true });
fs.writeFileSync(shimPath, '');
expect(findCliBinaryPath('pi', binDir, 'win32')).toBe(shimPath);
});
});