This repository was archived by the owner on Feb 19, 2026. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -44,16 +44,17 @@ if (napi.isNapiRuntime(rc.runtime)) napi.logUnsupportedVersion(rc.target, log)
4444
4545var pm = whichPmRuns ( )
4646var isNpm = ! pm || pm . name === 'npm'
47+ var origin = util . packageOrigin ( process . env , pkg )
4748
4849if ( ! isNpm && / n o d e _ m o d u l e s / . test ( process . cwd ( ) ) ) {
4950 // From yarn repository
5051} else if ( opts . force ) {
5152 log . warn ( 'install' , 'prebuilt binaries enforced with --force!' )
5253 log . warn ( 'install' , 'prebuilt binaries may be out of date!' )
53- } else if ( ! ( typeof pkg . _from === 'string' ) ) {
54+ } else if ( typeof origin !== 'string' ) {
5455 log . info ( 'install' , 'installing standalone, skipping download.' )
5556 process . exit ( 1 )
56- } else if ( pkg . _from . length > 4 && pkg . _from . substr ( 0 , 4 ) === 'git+' ) {
57+ } else if ( origin . length > 4 && origin . substr ( 0 , 4 ) === 'git+' ) {
5758 log . info ( 'install' , 'installing from git repository, skipping download.' )
5859 process . exit ( 1 )
5960} else if ( opts . compile === true || opts . prebuild === false ) {
Original file line number Diff line number Diff line change @@ -87,6 +87,19 @@ function tempFile (cached) {
8787 return cached + '.' + process . pid + '-' + Math . random ( ) . toString ( 16 ) . slice ( 2 ) + '.tmp'
8888}
8989
90+ function packageOrigin ( env , pkg ) {
91+ if ( env . npm_package_from ) {
92+ // npm 7: metadata is exposed to environment by arborist
93+ // TODO: seems undefined atm (npm 7.0.2)
94+ return env . npm_package_from
95+ }
96+
97+ if ( pkg . _from ) {
98+ // npm <= 6: metadata is stored on disk in node_modules
99+ return pkg . _from
100+ }
101+ }
102+
90103exports . getDownloadUrl = getDownloadUrl
91104exports . getApiUrl = getApiUrl
92105exports . getAssetUrl = getAssetUrl
@@ -95,3 +108,4 @@ exports.cachedPrebuild = cachedPrebuild
95108exports . prebuildCache = prebuildCache
96109exports . npmCache = npmCache
97110exports . tempFile = tempFile
111+ exports . packageOrigin = packageOrigin
You can’t perform that action at this time.
0 commit comments