mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
choose correct resolved package for peer dependencies (#7192)
* fix sometimes failing install test * loop to make sure it happens
This commit is contained in:
@@ -2793,10 +2793,6 @@ pub const PackageManager = struct {
|
||||
) !?ResolvedPackageResult {
|
||||
name.assertDefined();
|
||||
|
||||
if (resolution < this.lockfile.packages.len) {
|
||||
return .{ .package = this.lockfile.packages.get(resolution) };
|
||||
}
|
||||
|
||||
if (install_peer and behavior.isPeer()) {
|
||||
if (this.lockfile.package_index.get(name_hash)) |index| {
|
||||
const resolutions: []Resolution = this.lockfile.packages.items(.resolution);
|
||||
@@ -2875,6 +2871,10 @@ pub const PackageManager = struct {
|
||||
}
|
||||
}
|
||||
|
||||
if (resolution < this.lockfile.packages.len) {
|
||||
return .{ .package = this.lockfile.packages.get(resolution) };
|
||||
}
|
||||
|
||||
switch (version.tag) {
|
||||
.npm, .dist_tag => {
|
||||
if (version.tag == .npm) {
|
||||
|
||||
@@ -440,30 +440,32 @@ test("it should install with missing bun.lockb, node_modules, and/or cache", asy
|
||||
]);
|
||||
expect(await exited).toBe(0);
|
||||
|
||||
// delete bun.lockb
|
||||
await rm(join(packageDir, "bun.lockb"), { recursive: true, force: true });
|
||||
for (var i = 0; i < 150; i++) {
|
||||
// delete bun.lockb
|
||||
await rm(join(packageDir, "bun.lockb"), { recursive: true, force: true });
|
||||
|
||||
({ stdout, stderr, exited } = spawn({
|
||||
cmd: [bunExe(), "install"],
|
||||
cwd: packageDir,
|
||||
stdout: "pipe",
|
||||
stdin: "pipe",
|
||||
stderr: "pipe",
|
||||
env,
|
||||
}));
|
||||
({ stdout, stderr, exited } = spawn({
|
||||
cmd: [bunExe(), "install"],
|
||||
cwd: packageDir,
|
||||
stdout: "pipe",
|
||||
stdin: "pipe",
|
||||
stderr: "pipe",
|
||||
env,
|
||||
}));
|
||||
|
||||
err = await new Response(stderr).text();
|
||||
out = await new Response(stdout).text();
|
||||
expect(err).toContain("Saved lockfile");
|
||||
expect(err).not.toContain("not found");
|
||||
if (!err.includes("mimalloc: warning")) {
|
||||
expect(err).not.toContain("error:");
|
||||
err = await new Response(stderr).text();
|
||||
out = await new Response(stdout).text();
|
||||
expect(err).toContain("Saved lockfile");
|
||||
expect(err).not.toContain("not found");
|
||||
if (!err.includes("mimalloc: warning")) {
|
||||
expect(err).not.toContain("error:");
|
||||
}
|
||||
expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([
|
||||
"",
|
||||
expect.stringContaining("Checked 19 installs across 23 packages (no changes)"),
|
||||
]);
|
||||
expect(await exited).toBe(0);
|
||||
}
|
||||
expect(out.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([
|
||||
"",
|
||||
expect.stringContaining("Checked 19 installs across 23 packages (no changes)"),
|
||||
]);
|
||||
expect(await exited).toBe(0);
|
||||
|
||||
// delete cache
|
||||
await rm(join(packageDir, "node_modules", ".cache"), { recursive: true, force: true });
|
||||
|
||||
Reference in New Issue
Block a user