Compare commits

...

2 Commits

Author SHA1 Message Date
RiskyMH
a887676ce4 bun run zig-format 2025-01-16 02:36:45 +00:00
RiskyMH
e35fea5161 prefer bunfig.toml over .npmrc for install 2025-01-16 03:34:13 +01:00
3 changed files with 32 additions and 2 deletions

View File

@@ -535,5 +535,5 @@ const Fs = bun.fs;
const Loader = @import("./options.zig").Loader;
const resolver = @import("./resolver/resolver.zig");
const resolve_path = @import("./resolver/resolve_path.zig");
const Output = @import("./global.zig").Output;
const Output = @import("./Global.zig").Output;
const Environment = bun.Environment;

View File

@@ -8865,7 +8865,6 @@ pub const PackageManager = struct {
};
try bun.sys.chdir(fs.top_level_dir, fs.top_level_dir).unwrap();
try BunArguments.loadConfig(ctx.allocator, cli.config, ctx, .InstallCommand);
bun.copy(u8, &cwd_buf, fs.top_level_dir);
cwd_buf[fs.top_level_dir.len] = 0;
fs.top_level_dir = cwd_buf[0..fs.top_level_dir.len :0];
@@ -8911,6 +8910,9 @@ pub const PackageManager = struct {
break :brk install_;
}, env, true, &[_][:0]const u8{".npmrc"});
}
try BunArguments.loadConfig(ctx.allocator, cli.config, ctx, .InstallCommand);
const cpu_count = bun.getThreadCount();
const options = Options{

View File

@@ -372,3 +372,31 @@ it("bun pm migrate", async () => {
expect(hash).toMatchSnapshot();
});
it("should prefer bunfig.toml over .npmrc", async () => {
const urls: string[] = [];
setHandler(dummyRegistry(urls));
await Promise.all([
writeFile(join(package_dir, ".npmrc"), "cache = /tmp/npm/cache"),
writeFile(join(package_dir, "bunfig.toml"), '[install.cache]\ndir = "/tmp/bun/cache"'),
await writeFile(
join(package_dir, "package.json"),
JSON.stringify({
name: "foo",
version: "0.0.1",
}),
),
]);
const { stdout, stderr, exited } = spawn({
cmd: [bunExe(), "pm", "cache"],
cwd: package_dir,
stdout: "pipe",
stdin: "pipe",
stderr: "pipe",
env,
});
expect(await new Response(stderr).text()).toBe("");
expect(await new Response(stdout).text()).toBe("/tmp/bun/cache");
expect(await exited).toBe(0);
});