Files
bun.sh/test/cli/install/git-dependency.test.ts
Claude a3f269b13a Add resetOutputFlags for proper output handling
Added missing resetOutputFlags function to GitCommandRunner to properly set
output reader flags before starting, matching LifecycleScriptSubprocess behavior.
This ensures correct handling of nonblocking I/O and socket flags.

Also updated test to use smaller repository to avoid timeouts.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-12 00:17:35 +02:00

90 lines
2.5 KiB
TypeScript

import { spawnSync } from "bun";
import { expect, test } from "bun:test";
import { bunEnv, bunExe, tempDirWithFiles } from "harness";
import { join } from "path";
import { existsSync } from "fs";
test("install github dependency", async () => {
const dir = tempDirWithFiles("test-github-install", {
"package.json": JSON.stringify({
name: "test-github-install",
dependencies: {
// Using github: shorthand which downloads as tarball
"awesome-bun": "github:oven-sh/awesome-bun",
},
}),
});
const result = spawnSync({
cmd: [bunExe(), "install"],
env: bunEnv,
cwd: dir,
stdout: "pipe",
stderr: "pipe",
});
expect(result.exitCode).toBe(0);
expect(result.stderr.toString()).not.toContain("error");
// Check that the package was installed
const packagePath = join(dir, "node_modules", "awesome-bun");
expect(existsSync(packagePath)).toBe(true);
// Should have README.md
const readmePath = join(packagePath, "README.md");
expect(existsSync(readmePath)).toBe(true);
});
test("install git+https URL dependency", async () => {
const dir = tempDirWithFiles("test-git-url", {
"package.json": JSON.stringify({
name: "test-git-url",
dependencies: {
// Using git+ prefix which triggers git clone - use a smaller repo
"awesome-bun": "git+https://github.com/oven-sh/awesome-bun.git#main",
},
}),
});
const result = spawnSync({
cmd: [bunExe(), "install"],
env: bunEnv,
cwd: dir,
stdout: "pipe",
stderr: "pipe",
});
expect(result.exitCode).toBe(0);
expect(result.stderr.toString()).not.toContain("error");
// Check that the package was installed
const packagePath = join(dir, "node_modules", "awesome-bun");
expect(existsSync(packagePath)).toBe(true);
});
test("install git URL without commit hash", async () => {
const dir = tempDirWithFiles("test-git-no-hash", {
"package.json": JSON.stringify({
name: "test-git-no-hash",
dependencies: {
// Using HEAD of default branch
"awesome-bun-2": "git+https://github.com/oven-sh/awesome-bun.git",
},
}),
});
const result = spawnSync({
cmd: [bunExe(), "install"],
env: bunEnv,
cwd: dir,
stdout: "pipe",
stderr: "pipe",
});
expect(result.exitCode).toBe(0);
expect(result.stderr.toString()).not.toContain("error");
// Check that the package was installed
const packagePath = join(dir, "node_modules", "awesome-bun-2");
expect(existsSync(packagePath)).toBe(true);
});