From 50e025c7a75c679f878caaefc61cc9979ff5475b Mon Sep 17 00:00:00 2001 From: Artem Derevnjuk Date: Mon, 15 Apr 2024 10:40:15 +0400 Subject: [PATCH] fix: add support for Node.js v21 (#40) Requires a patch as outlined in nodejs/node#52475 --- .github/workflows/deploy.yml | 14 ++++++++++++-- package.json | 4 ++-- patches/node-gyp-build+4.8.0.patch | 23 +++++++++++++++++++++++ patches/prebuildify+6.0.0.patch | 4 ++-- 4 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 patches/node-gyp-build+4.8.0.patch diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1be23af..e14f9ab 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -40,12 +40,22 @@ jobs: - uses: actions/upload-artifact@v4 with: - name: build-artifacts + name: build-artifacts-${{ matrix.node_arch }} path: prebuilds/ if-no-files-found: error - deploy: + merge: + runs-on: ubuntu-latest needs: build + steps: + - name: Merge Artifacts + uses: actions/upload-artifact/merge@v4 + with: + name: build-artifacts + pattern: build-artifacts-* + + deploy: + needs: merge runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/package.json b/package.json index 6c38cdf..2ed390c 100644 --- a/package.json +++ b/package.json @@ -70,8 +70,8 @@ }, "scripts": { "semantic-release": "semantic-release", - "build:gyp": "prebuildify --strip --target 10.24.1 --target 12.22.12 --target 14.21.3 --target 16.20.2 --target 18.17.1 --target 19.9.0 --target 20.5.1", - "build:gyp-cross": "prebuildify-cross --strip --target 10.24.1 --target 12.22.12 --target 14.21.3 --target 16.20.2 --target 18.17.1 --target 19.9.0 --target 20.5.1", + "build:gyp": "prebuildify --strip --target 10.24.1 --target 12.22.12 --target 14.21.3 --target 16.20.2 --target 18.17.1 --target 19.9.0 --target 20.12.2 --target 21.7.3", + "build:gyp-cross": "prebuildify-cross --strip --target 10.24.1 --target 12.22.12 --target 14.21.3 --target 16.20.2 --target 18.17.1 --target 19.9.0 --target 20.12.2 --target 21.7.3", "native_install": "node-gyp-build", "install": "node scripts/install.js", "prepare": "is-ci || husky install", diff --git a/patches/node-gyp-build+4.8.0.patch b/patches/node-gyp-build+4.8.0.patch new file mode 100644 index 0000000..0677c9e --- /dev/null +++ b/patches/node-gyp-build+4.8.0.patch @@ -0,0 +1,23 @@ +diff --git a/node_modules/node-gyp-build/bin.js b/node_modules/node-gyp-build/bin.js +index 3fbcdf0..5aacdf4 100755 +--- a/node_modules/node-gyp-build/bin.js ++++ b/node_modules/node-gyp-build/bin.js +@@ -27,7 +27,7 @@ function build () { + ] + } catch (_) {} + +- proc.spawn(args[0], args.slice(1), { stdio: 'inherit' }).on('exit', function (code) { ++ proc.spawn(args[0], args.slice(1), { stdio: 'inherit', ...(os.platform() === 'win32' ? { shell: true, windowsVerbatimArguments: true } : {}) }).on('exit', function (code) { + if (code || !process.argv[3]) process.exit(code) + exec(process.argv[3]).on('exit', function (code) { + process.exit(code) +@@ -53,7 +53,8 @@ function exec (cmd) { + + return proc.spawn(process.env.comspec || 'cmd.exe', ['/s', '/c', '"' + cmd + '"'], { + windowsVerbatimArguments: true, +- stdio: 'inherit' ++ stdio: 'inherit', ++ shell: true + }) + } + diff --git a/patches/prebuildify+6.0.0.patch b/patches/prebuildify+6.0.0.patch index e398f53..65c554f 100644 --- a/patches/prebuildify+6.0.0.patch +++ b/patches/prebuildify+6.0.0.patch @@ -1,5 +1,5 @@ diff --git a/node_modules/prebuildify/index.js b/node_modules/prebuildify/index.js -index ca9829a..0ab2d39 100644 +index ca9829a..ffbb682 100644 --- a/node_modules/prebuildify/index.js +++ b/node_modules/prebuildify/index.js @@ -230,7 +230,8 @@ function build (target, runtime, opts, cb) { @@ -8,7 +8,7 @@ index ca9829a..0ab2d39 100644 env: opts.env, - stdio: opts.quiet ? 'ignore' : 'inherit' + stdio: opts.quiet ? 'ignore' : 'inherit', -+ shell: opts.shell ++ shell: true }) child.on('exit', function (code) {