Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,219 changes: 1,720 additions & 499 deletions bun.lock

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions cli/src/utils/spawnHappyCLI.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { beforeAll, afterAll, beforeEach, describe, expect, it, vi } from 'vitest';
import type { SpawnOptions } from 'child_process';
import { join } from 'node:path';
import { projectPath } from '@/projectPath';

const spawnMock = vi.fn((..._args: any[]) => ({ pid: 12345 } as any));

Expand Down Expand Up @@ -31,6 +33,10 @@ function getSpawnOptionsOrThrow(): SpawnOptions {
return options;
}

function normalizePath(value: string): string {
return value.replace(/\\/g, '/');
}

describe('spawnHappyCLI windowsHide behavior', () => {
beforeAll(() => {
if (!originalPlatformDescriptor?.configurable) {
Expand Down Expand Up @@ -97,17 +103,19 @@ describe('spawnHappyCLI windowsHide behavior', () => {

it('forces Bun child processes to run with the cli project root as cwd', async () => {
const { getHappyCliCommand } = await import('./spawnHappyCLI');
const expectedProjectRoot = projectPath();
const expectedEntrypoint = join(expectedProjectRoot, 'src', 'index.ts');

const command = getHappyCliCommand(['mcp', '--url', 'http://127.0.0.1:1234/']);
const isBunRuntime = Boolean((process.versions as Record<string, string | undefined>).bun);

expect(command.command).toBe(process.execPath);
if (isBunRuntime) {
expect(command.args[0]).toBe('--cwd');
expect(command.args[1].replace(/\\/g, '/')).toMatch(/\/hapi\/cli$/);
expect(command.args[2].replace(/\\/g, '/')).toMatch(/\/hapi\/cli\/src\/index\.ts$/);
expect(normalizePath(command.args[1])).toBe(normalizePath(expectedProjectRoot));
expect(normalizePath(command.args[2])).toBe(normalizePath(expectedEntrypoint));
} else {
expect(command.args.some((arg) => arg.replace(/\\/g, '/').endsWith('/hapi/cli/src/index.ts'))).toBe(true);
expect(command.args.some((arg) => normalizePath(arg) === normalizePath(expectedEntrypoint))).toBe(true);
}
});

Expand Down
Loading
Loading