aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bun.js/module_loader.zig9
-rw-r--r--src/install/install.zig19
-rw-r--r--src/install/lockfile.zig4
-rw-r--r--src/resolver/resolver.zig3
-rw-r--r--test/bun.js/child-process-stdio.test.js11
5 files changed, 22 insertions, 24 deletions
diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig
index 023c96fbc..b689dea83 100644
--- a/src/bun.js/module_loader.zig
+++ b/src/bun.js/module_loader.zig
@@ -396,11 +396,13 @@ pub const ModuleLoader = struct {
}
pub fn onExtract(this: *Queue, package_id: u32, comptime _: PackageManager.Options.LogLevel) void {
- if (comptime Environment.allow_assert)
+ if (comptime Environment.allow_assert) {
+ const lockfile = this.vm().packageManager().lockfile;
debug("onExtract: {s} ({d})", .{
- this.vm().packageManager().lockfile.str(&this.vm().packageManager().lockfile.packages.get(package_id).name),
+ lockfile.str(&lockfile.packages.get(package_id).name),
package_id,
});
+ }
this.onPackageID(package_id);
}
@@ -726,7 +728,8 @@ pub const ModuleLoader = struct {
bun.default_allocator,
"{s} downloading package '{s}@{any}'",
.{
- std.mem.span(@errorName(err)), result.name,
+ std.mem.span(@errorName(err)),
+ result.name,
result.resolution.fmt(vm.packageManager().lockfile.buffers.string_bytes.items),
},
),
diff --git a/src/install/install.zig b/src/install/install.zig
index 076977aa8..c630732a1 100644
--- a/src/install/install.zig
+++ b/src/install/install.zig
@@ -1629,7 +1629,7 @@ pub const PackageManager = struct {
return .done;
}
- const folder_path = manager.cachedNPMPackageFolderName(this.name.slice(lockfile.buffers.string_bytes.items), this.resolution.value.npm.version);
+ const folder_path = manager.cachedNPMPackageFolderName(lockfile.str(&this.name), this.resolution.value.npm.version);
if (manager.isFolderInCache(folder_path)) {
manager.setPreinstallState(this.meta.id, lockfile, .done);
return .done;
@@ -2227,7 +2227,7 @@ pub const PackageManager = struct {
.folder => {
// relative to cwd
- const res = FolderResolution.getOrPut(.{ .relative = .folder }, version, version.value.folder.slice(this.lockfile.buffers.string_bytes.items), this);
+ const res = FolderResolution.getOrPut(.{ .relative = .folder }, version, this.lockfile.str(&version.value.folder), this);
switch (res) {
.err => |err| return err,
@@ -2244,7 +2244,7 @@ pub const PackageManager = struct {
},
.workspace => {
// relative to cwd
- const res = FolderResolution.getOrPut(.{ .relative = .workspace }, version, version.value.workspace.slice(this.lockfile.buffers.string_bytes.items), this);
+ const res = FolderResolution.getOrPut(.{ .relative = .workspace }, version, this.lockfile.str(&version.value.workspace), this);
switch (res) {
.err => |err| return err,
@@ -2260,7 +2260,7 @@ pub const PackageManager = struct {
}
},
.symlink => {
- const res = FolderResolution.getOrPut(.{ .global = try this.globalLinkDirPath() }, version, version.value.symlink.slice(this.lockfile.buffers.string_bytes.items), this);
+ const res = FolderResolution.getOrPut(.{ .global = try this.globalLinkDirPath() }, version, this.lockfile.str(&version.value.symlink), this);
switch (res) {
.err => |err| return err,
@@ -5500,9 +5500,7 @@ pub const PackageManager = struct {
package_id: PackageID,
comptime log_level: Options.LogLevel,
) void {
- const buf = this.lockfile.buffers.string_bytes.items;
-
- const name = this.names[package_id].slice(buf);
+ const name = this.lockfile.str(&this.names[package_id]);
const resolution = this.resolutions[package_id];
if (this.manager.task_queue.fetchRemove(Task.Id.forNPMPackage(
@@ -5773,8 +5771,7 @@ pub const PackageManager = struct {
return;
}
- const buf = this.lockfile.buffers.string_bytes.items;
- const name = this.names[package_id].slice(buf);
+ const name = this.lockfile.str(&this.names[package_id]);
const resolution = this.resolutions[package_id];
this.installPackageWithNameAndResolution(package_id, log_level, name, resolution);
@@ -6007,7 +6004,7 @@ pub const PackageManager = struct {
// Don't attempt to link incompatible binaries
if (meta.isDisabled()) continue;
- const name: string = installer.names[resolved_id].slice(lockfile.buffers.string_bytes.items);
+ const name: string = lockfile.str(&installer.names[resolved_id]);
if (!installer.has_created_bin) {
if (!this.options.global) {
@@ -6057,7 +6054,7 @@ pub const PackageManager = struct {
if (comptime log_level != .silent) {
const fmt = "\n<r><yellow>warn:<r> no compatible binaries found for <b>{s}<r>\n";
- const args = .{names[package_id].slice(lockfile.buffers.string_bytes.items)};
+ const args = .{lockfile.str(&names[package_id])};
if (comptime log_level.showProgress()) {
if (Output.enable_ansi_colors) {
diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig
index 3fcfd0ea1..9274b1b40 100644
--- a/src/install/lockfile.zig
+++ b/src/install/lockfile.zig
@@ -574,9 +574,7 @@ fn preprocessUpdateRequests(old: *Lockfile, updates: []PackageManager.UpdateRequ
const res = resolutions_of_yore[old_resolution];
var buf = std.fmt.bufPrint(&temp_buf, "^{}", .{res.value.npm.fmt(old.buffers.string_bytes.items)}) catch break;
const external_version = string_builder.append(ExternalString, buf);
- const sliced = external_version.value.sliced(
- old.buffers.string_bytes.items,
- );
+ const sliced = external_version.value.sliced(old.buffers.string_bytes.items);
dep.version = Dependency.parse(
old.allocator,
dep.name,
diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig
index 75637a72c..f2a81a35a 100644
--- a/src/resolver/resolver.zig
+++ b/src/resolver/resolver.zig
@@ -1528,8 +1528,7 @@ pub const Resolver = struct {
}
for (dependencies_list) |dependency, dependency_id| {
- const dep_name_ = &dependency.name;
- const dep_name = dep_name_.slice(string_buf);
+ const dep_name = dependency.name.slice(string_buf);
if (dep_name.len == esm.name.len) {
if (!strings.eqlLong(dep_name, esm.name, false)) {
continue;
diff --git a/test/bun.js/child-process-stdio.test.js b/test/bun.js/child-process-stdio.test.js
index a023a6e03..5e295b2ca 100644
--- a/test/bun.js/child-process-stdio.test.js
+++ b/test/bun.js/child-process-stdio.test.js
@@ -1,12 +1,13 @@
import { describe, it, expect, beforeAll } from "bun:test";
import { spawn, execSync } from "node:child_process";
+import { bunExe } from "bunExe";
const CHILD_PROCESS_FILE = import.meta.dir + "/spawned-child.js";
const OUT_FILE = import.meta.dir + "/stdio-test-out.txt";
describe("process.stdout", () => {
it("should allow us to write to it", (done) => {
- const child = spawn("bun", [CHILD_PROCESS_FILE, "STDOUT"]);
+ const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDOUT"]);
child.stdout.setEncoding("utf8");
child.stdout.on("data", (data) => {
try {
@@ -23,7 +24,7 @@ describe("process.stdin", () => {
it("should allow us to read from stdin in readable mode", (done) => {
const input = "hello\n";
// Child should read from stdin and write it back
- const child = spawn("bun", [CHILD_PROCESS_FILE, "STDIN", "READABLE"]);
+ const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDIN", "READABLE"]);
let data = "";
child.stdout.setEncoding("utf8");
child.stdout.on("data", (chunk) => {
@@ -43,7 +44,7 @@ describe("process.stdin", () => {
it("should allow us to read from stdin via flowing mode", (done) => {
const input = "hello\n";
// Child should read from stdin and write it back
- const child = spawn("bun", [CHILD_PROCESS_FILE, "STDIN", "FLOWING"]);
+ const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDIN", "FLOWING"]);
let data = "";
child.stdout.setEncoding("utf8");
child.stdout.on("readable", () => {
@@ -67,7 +68,7 @@ describe("process.stdin", () => {
const numReps = Math.ceil((66 * 1024) / 5);
const input = "hello".repeat(numReps);
// Child should read from stdin and write it back
- const child = spawn("bun", [CHILD_PROCESS_FILE, "STDIN", "FLOWING"]);
+ const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDIN", "FLOWING"]);
let data = "";
child.stdout.setEncoding("utf8");
child.stdout.on("readable", () => {
@@ -89,7 +90,7 @@ describe("process.stdin", () => {
it("should allow us to read from a file", () => {
const result = execSync(
- `bun ${CHILD_PROCESS_FILE} STDIN FLOWING < ${
+ `${bunExe()} ${CHILD_PROCESS_FILE} STDIN FLOWING < ${
import.meta.dir
}/readFileSync.txt`,
{ encoding: "utf8" },