This commit is contained in:
RiskyMH
2025-02-03 14:01:32 +00:00
parent 97984890f7
commit d8b5f60ac6
4 changed files with 10 additions and 8 deletions

View File

@@ -3499,6 +3499,7 @@ pub fn selfExePath() ![:0]u8 {
return memo.load();
}
pub const exe_suffix = if (Environment.isWindows) ".exe" else "";
pub var is_standalone: ?bool = null;
pub const spawnSync = @This().spawn.sync.spawn;

View File

@@ -1766,6 +1766,8 @@ pub const Command = struct {
// bun build --compile entry point
if (try bun.StandaloneModuleGraph.fromExecutable(bun.default_allocator)) |graph| {
bun.is_standalone = true;
context_data = .{
.args = std.mem.zeroes(Api.TransformOptions),
.log = log,

View File

@@ -4827,15 +4827,15 @@ pub const Interpreter = struct {
defer bun.PathBufferPool.put(path_buf);
const resolved = blk: {
if (bun.strings.eqlComptime(first_arg_real, "bun") or bun.strings.eqlComptime(first_arg_real, "bun-debug")) blk2: {
spawn_args.env_array.append(arena_allocator, "BUN_SKIP_STANDALONE_MODULE_GRAPH=1") catch break :blk2;
if (bun.is_standalone == true) spawn_args.env_array.append(arena_allocator, "BUN_SKIP_STANDALONE_MODULE_GRAPH=1") catch break :blk2;
break :blk bun.selfExePath() catch break :blk2;
}
// if (bun.strings.eqlComptime(first_arg_real, "bunx")) blk2: {
// spawn_args.env_array.append(arena_allocator, "BUN_SKIP_STANDALONE_MODULE_GRAPH=1") catch break :blk2;
// this.args.insert(1, "x") catch bun.outOfMemory();
// break :blk bun.selfExePath() catch break :blk2;
// }
if (bun.strings.eqlComptime(first_arg_real, "bunx")) blk2: {
if (bun.is_standalone == true) spawn_args.env_array.append(arena_allocator, "BUN_SKIP_STANDALONE_MODULE_GRAPH=1") catch break :blk2;
this.args.insert(1, "x") catch break :blk2;
break :blk bun.selfExePath() catch break :blk2;
}
break :blk which(path_buf, spawn_args.PATH, spawn_args.cwd, first_arg_real) orelse {
this.writeFailingError("bun: command not found: {s}\n", .{first_arg});

View File

@@ -105,9 +105,8 @@ describe("bun build", () => {
expect(exitCode2).toBe(0);
// bunx
// Bun.$``.nothrow
const srcX = path.join(tmp, "indexx.js");
fs.writeFileSync(srcX, 'console.log(await Bun.$`bunx cowsay hi`.text());', {
fs.writeFileSync(srcX, "console.log(await Bun.$`bunx cowsay hi`.text());", {
encoding: "utf8",
});
const outfileX = path.join(tmp, "indexx.exe");