Replace some of std.ChildProcess with bun.spawnSync (#9513)

* Replace some of std.ChildProcess with bun.spawnSync

* Update process.zig

* Fix some build errors

* Fix linux build

* Keep error

* Don't print a mesasge in this case

* Update spawn.test.ts

* Make `bun install` faster on Linux

* Comments + edgecases

* Fix the tests

* Add bun install launch.json

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Zack Radisic <zack@theradisic.com>
This commit is contained in:
Jarred Sumner
2024-03-21 23:50:48 -07:00
committed by GitHub
parent 7e3e7d2ed4
commit 2d61c865fc
19 changed files with 1132 additions and 466 deletions

View File

@@ -23,6 +23,10 @@ pub fn initCapacity(
};
}
pub fn countZ(this: *StringBuilder, slice: string) void {
this.cap += slice.len + 1;
}
pub fn count(this: *StringBuilder, slice: string) void {
this.cap += slice.len;
}
@@ -50,6 +54,22 @@ pub fn append16(this: *StringBuilder, slice: []const u16) ?[:0]u8 {
return null;
}
pub fn appendZ(this: *StringBuilder, slice: string) [:0]const u8 {
if (comptime Environment.allow_assert) {
assert(this.len + 1 <= this.cap); // didn't count everything
assert(this.ptr != null); // must call allocate first
}
bun.copy(u8, this.ptr.?[this.len..this.cap], slice);
this.ptr.?[this.len + slice.len] = 0;
const result = this.ptr.?[this.len..this.cap][0..slice.len :0];
this.len += slice.len + 1;
if (comptime Environment.allow_assert) assert(this.len <= this.cap);
return result;
}
pub fn append(this: *StringBuilder, slice: string) string {
if (comptime Environment.allow_assert) {
assert(this.len <= this.cap); // didn't count everything