Skip to content

Commit

Permalink
maybe?
Browse files Browse the repository at this point in the history
  • Loading branch information
RiskyMH committed Feb 3, 2025
1 parent 9798489 commit d8b5f60
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/bun.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/cli.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions src/shell/interpreter.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
3 changes: 1 addition & 2 deletions test/bundler/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit d8b5f60

Please sign in to comment.