From c93edb55f52532e666a9ba2719bee0da725fe6f0 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Wed, 25 Oct 2023 09:46:29 -0700 Subject: [PATCH] fix: add back `bin/node-gyp-bin/node-gyp` files This was an unintended breaking change as part of #6554. The `node-gyp` bin files are not used by the CLI directly but they are relied on by other tooling. This change is only intended to land on the v9 release line. This partially reverts commit 3a7378d889707d2a4c1f8a6397dda87825e9f5a3. --- bin/node-gyp-bin/node-gyp | 6 ++++++ bin/node-gyp-bin/node-gyp.cmd | 5 +++++ test/bin/windows-shims.js | 7 ++++--- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100755 bin/node-gyp-bin/node-gyp create mode 100755 bin/node-gyp-bin/node-gyp.cmd diff --git a/bin/node-gyp-bin/node-gyp b/bin/node-gyp-bin/node-gyp new file mode 100755 index 0000000000000..70efb6f339f76 --- /dev/null +++ b/bin/node-gyp-bin/node-gyp @@ -0,0 +1,6 @@ +#!/usr/bin/env sh +if [ "x$npm_config_node_gyp" = "x" ]; then + node "`dirname "$0"`/../../node_modules/node-gyp/bin/node-gyp.js" "$@" +else + "$npm_config_node_gyp" "$@" +fi diff --git a/bin/node-gyp-bin/node-gyp.cmd b/bin/node-gyp-bin/node-gyp.cmd new file mode 100755 index 0000000000000..1ef2ae0c68fc4 --- /dev/null +++ b/bin/node-gyp-bin/node-gyp.cmd @@ -0,0 +1,5 @@ +if not defined npm_config_node_gyp ( + node "%~dp0\..\..\node_modules\node-gyp\bin\node-gyp.js" %* +) else ( + node "%npm_config_node_gyp%" %* +) diff --git a/test/bin/windows-shims.js b/test/bin/windows-shims.js index 29c257fc7954d..8769f2a905458 100644 --- a/test/bin/windows-shims.js +++ b/test/bin/windows-shims.js @@ -1,7 +1,7 @@ const t = require('tap') const { spawnSync } = require('child_process') const { resolve, join, extname, basename, sep } = require('path') -const { readFileSync, chmodSync, readdirSync } = require('fs') +const { readFileSync, chmodSync, readdirSync, statSync } = require('fs') const Diff = require('diff') const { sync: which } = require('which') const { version } = require('../../package.json') @@ -10,8 +10,9 @@ const ROOT = resolve(__dirname, '../..') const BIN = join(ROOT, 'bin') const NODE = readFileSync(process.execPath) const SHIMS = readdirSync(BIN).reduce((acc, shim) => { - if (extname(shim) !== '.js') { - acc[shim] = readFileSync(join(BIN, shim), 'utf-8') + const p = join(BIN, shim) + if (extname(p) !== '.js' && !statSync(p).isDirectory()) { + acc[shim] = readFileSync(p, 'utf-8') } return acc }, {})