fix(install) make sure node-gyp is available during lifecycle scripts (#7622)

* bunx node-gyp

* add test

* create temp node-gyp when used in script

* windows reminder

* closer?

* Update bunx_command.zig

* append fake node to end of path

* Update install.zig

* correct temp node-gyp dir, always append parent `node_modules/.bin` dir

* make sure temp node-gyp doesnt run itself

---------

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
Dylan Conway
2023-12-13 23:19:37 -08:00
committed by GitHub
parent c0ccdccbeb
commit 36c316a24a
5 changed files with 266 additions and 58 deletions

View File

@@ -459,20 +459,20 @@ pub const RunCommand = struct {
this_bundler.configureLinker();
}
const bun_node_dir = switch (@import("builtin").target.os.tag) {
pub const bun_node_dir = switch (@import("builtin").target.os.tag) {
// TODO:
.windows => "TMPDIR",
.macos => "/private/tmp",
else => "/tmp",
} ++ if (!Environment.isDebug)
"/bun-node-" ++ Environment.git_sha_short
"/bun-node" ++ if (Environment.git_sha_short.len > 0) "-" ++ Environment.git_sha_short else ""
else
"/bun-debug-node";
"/bun-debug-node" ++ (if (Environment.git_sha_short.len > 0) "-" ++ Environment.git_sha_short else "");
var self_exe_bin_path_buf: [bun.MAX_PATH_BYTES + 1]u8 = undefined;
fn createFakeTemporaryNodeExecutable(PATH: *std.ArrayList(u8), optional_bun_path: *string) !void {
pub fn createFakeTemporaryNodeExecutable(PATH: *std.ArrayList(u8), optional_bun_path: *string) !void {
// If we are already running as "node", the path should exist
if (CLI.pretend_to_be_node) return;
@@ -514,7 +514,7 @@ pub const RunCommand = struct {
break;
}
if (PATH.items.len > 0) {
if (PATH.items.len > 0 and PATH.items[PATH.items.len - 1] != std.fs.path.delimiter) {
try PATH.append(std.fs.path.delimiter);
}