fix: node-gyp regression introduced in 5.13.2

close #2988
PR #2991
This commit is contained in:
Zoltan Kochan
2020-11-22 03:49:26 +02:00
committed by GitHub
parent faa785b71c
commit 048fc5f68c
7 changed files with 84 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"pnpm": patch
---
Fix regression with node-gyp.

View File

@@ -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

View File

@@ -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%" %*
)

View File

@@ -15,6 +15,7 @@
"lib/pnpm.js",
"lib/pnpx.js",
"lib/node_modules",
"lib/node-gyp-bin",
"bin"
],
"dependencies": {
@@ -100,6 +101,7 @@
"read-yaml-file": "^2.0.0",
"render-help": "^1.0.1",
"semver": "^7.3.2",
"shx": "^0.3.3",
"split-cmd": "^1.0.1",
"strip-ansi": "^6.0.0",
"symlink-dir": "^4.1.0",
@@ -162,7 +164,7 @@
"test": "pnpm run compile && pnpm run _test",
"prepublishOnly": "pnpm compile && npm cache clear --force && publish-packed --prune --npm-client yarn",
"postpublish": "publish-packed",
"compile": "rimraf lib tsconfig.tsbuildinfo && tsc --build && pnpm run bundle"
"compile": "rimraf lib tsconfig.tsbuildinfo && tsc --build && shx cp -r node-gyp-bin lib/node-gyp-bin && pnpm run bundle"
},
"publishconfig": {
"tag": "next"

View File

@@ -3,6 +3,7 @@ import { PackageManifest } from '@pnpm/types'
import promisifyTape from 'tape-promise'
import { execPnpmSync } from '../utils'
import path = require('path')
import PATH = require('path-name')
import loadJsonFile = require('load-json-file')
import tape = require('tape')
@@ -150,3 +151,28 @@ test('dependency should not be added to package.json and lockfile if it was not
const pkg = await import(path.resolve('package.json'))
t.deepEqual(pkg, { name: 'foo', version: '1.0.0' }, 'package.json not updated')
})
test('node-gyp is in the PATH', async (t) => {
prepare(t, {
scripts: {
test: 'node-gyp --help',
},
})
// `npm test` adds node-gyp to the PATH
// it is removed here to test that pnpm adds it
const initialPath = process.env.PATH
if (typeof initialPath !== 'string') throw new Error('PATH is not defined')
process.env[PATH] = initialPath
.split(path.delimiter)
.filter((p: string) => !p.includes('node-gyp-bin') && !p.includes('npm'))
.join(path.delimiter)
const result = execPnpmSync(['test'])
process.env[PATH] = initialPath
t.equal(result.status, 0)
})

37
pnpm-lock.yaml generated
View File

@@ -2262,6 +2262,7 @@ importers:
read-yaml-file: 2.0.0
render-help: 1.0.1
semver: 7.3.2
shx: 0.3.3
split-cmd: 1.0.1
strip-ansi: 6.0.0
symlink-dir: 4.1.0
@@ -2351,6 +2352,7 @@ importers:
read-yaml-file: ^2.0.0
render-help: ^1.0.1
semver: ^7.3.2
shx: ^0.3.3
split-cmd: ^1.0.1
strip-ansi: ^6.0.0
symlink-dir: ^4.1.0
@@ -8670,6 +8672,12 @@ packages:
dev: true
resolution:
integrity: sha1-dEi/qSQJKvMR1HFzu6uZDK4rsCc=
/interpret/1.4.0:
dev: true
engines:
node: '>= 0.10'
resolution:
integrity: sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==
/ip-regex/2.1.0:
dev: true
engines:
@@ -12166,6 +12174,14 @@ packages:
node: '>=10'
resolution:
integrity: sha512-X6VKspeG3XYaSJovVE39AOis+M/DNmVlsKvbhvmI3t2Su8/VN1lrIqLwEznowYedNYg5jLIx2OMjo7oIRJpmEQ==
/rechoir/0.6.2:
dependencies:
resolve: 1.19.0
dev: true
engines:
node: '>= 0.10'
resolution:
integrity: sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=
/redent/1.0.0:
dependencies:
indent-string: 2.1.0
@@ -12793,11 +12809,32 @@ packages:
dev: true
resolution:
integrity: sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==
/shelljs/0.8.4:
dependencies:
glob: 7.1.6
interpret: 1.4.0
rechoir: 0.6.2
dev: true
engines:
node: '>=4'
hasBin: true
resolution:
integrity: sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==
/shellwords/0.1.1:
dev: true
optional: true
resolution:
integrity: sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==
/shx/0.3.3:
dependencies:
minimist: 1.2.5
shelljs: 0.8.4
dev: true
engines:
node: '>=6'
hasBin: true
resolution:
integrity: sha512-nZJ3HFWVoTSyyB+evEKjJ1STiixGztlqwKLTUNV5KqMWtGey9fTd4KU1gdZ1X9BV6215pswQ/Jew9NsuS/fNDA==
/signal-exit/3.0.3:
resolution:
integrity: sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==

View File

@@ -130,7 +130,7 @@ async function updateManifest (dir: string, manifest: ProjectManifest) {
type: 'git',
url: 'git+https://github.com/pnpm/pnpm.git',
}
scripts.compile += ' && pnpm run bundle'
scripts.compile += ' && shx cp -r node-gyp-bin lib/node-gyp-bin && pnpm run bundle'
} else {
scripts.prepublishOnly = 'pnpm run compile'
homepage = `https://github.com/pnpm/pnpm/blob/master/${relative}#readme`
@@ -148,6 +148,7 @@ async function updateManifest (dir: string, manifest: ProjectManifest) {
files.push('lib/pnpm.js')
files.push('lib/pnpx.js')
files.push('lib/node_modules')
files.push('lib/node-gyp-bin')
files.push('bin')
} else {
// the order is important