node-install-release 1.16.1 → 1.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/cli.d.cts +0 -0
- package/dist/cjs/cli.d.ts +0 -0
- package/dist/cjs/cli.js +0 -0
- package/dist/cjs/compat.js.map +1 -1
- package/dist/cjs/workers/install.js +54 -62
- package/dist/cjs/workers/install.js.map +1 -1
- package/dist/esm/cli.d.ts +0 -0
- package/dist/esm/cli.js +0 -0
- package/dist/esm/compat.js +2 -2
- package/dist/esm/compat.js.map +1 -1
- package/dist/esm/workers/install.js +50 -58
- package/dist/esm/workers/install.js.map +1 -1
- package/package.json +16 -16
package/dist/cjs/cli.d.cts
CHANGED
|
File without changes
|
package/dist/cjs/cli.d.ts
CHANGED
|
File without changes
|
package/dist/cjs/cli.js
CHANGED
|
File without changes
|
package/dist/cjs/compat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\nimport os from 'os';\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\nimport os from 'os';\n\nconst hasHomedir = typeof os.homedir === 'function';\n\nexport function homedir(): string {\n if (hasHomedir) {\n return os.homedir();\n }\n const home = require('homedir-polyfill');\n return home();\n}\n"],"names":["homedir","hasHomedir","os","home","require"],"mappings":"AAAA;;;CAGC;;;;+BAKeA;;;eAAAA;;;yDAJD;;;;;;AAEf,IAAMC,aAAa,OAAOC,WAAE,CAACF,OAAO,KAAK;AAElC,SAASA;IACd,IAAIC,YAAY;QACd,OAAOC,WAAE,CAACF,OAAO;IACnB;IACA,IAAMG,OAAOC,QAAQ;IACrB,OAAOD;AACT"}
|
|
@@ -84,80 +84,72 @@ function install(versionExpression, options, callback) {
|
|
|
84
84
|
}
|
|
85
85
|
var version = versions[0];
|
|
86
86
|
var result = (0, _createResultts.default)(options, version);
|
|
87
|
-
// Fast path:
|
|
88
|
-
|
|
89
|
-
if (err) {
|
|
90
|
-
callback(err);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
// Early exit if both node and npm are already present
|
|
94
|
-
if (!missing.length) {
|
|
87
|
+
// Fast path: with atomic installs, folder exists = complete installation
|
|
88
|
+
_fs.default.stat(result.installPath, function(err) {
|
|
89
|
+
if (!err) {
|
|
95
90
|
callback(null, result);
|
|
96
91
|
return;
|
|
97
92
|
}
|
|
98
|
-
//
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (bundledNpmMajor >= 3) {
|
|
120
|
-
cb(); // npm >= 3 bundled, skip download
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
// old npm (<3) is buggy - delete it so installNPM can override
|
|
124
|
-
var platform = options.platform;
|
|
125
|
-
var libPath = platform === 'win32' ? tempPath : _path.default.join(tempPath, 'lib');
|
|
126
|
-
var npmPath = _path.default.join(libPath, 'node_modules', 'npm');
|
|
127
|
-
(0, _fsremovecompat.safeRm)(npmPath, function() {
|
|
128
|
-
return (0, _indexts1.default)(version, tempPath, options, cb);
|
|
129
|
-
});
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
(0, _indexts1.default)(version, tempPath, options, cb);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
// Atomic rename: move temp folder to final destination
|
|
136
|
-
queue.defer(function(cb) {
|
|
137
|
-
_fs.default.rename(tempPath, result.installPath, function(err) {
|
|
138
|
-
if (!err) return cb();
|
|
139
|
-
// Race condition: another process may have already created dest
|
|
140
|
-
if (err.code === 'EEXIST' || err.code === 'ENOTEMPTY' || err.code === 'EPERM') {
|
|
141
|
-
// Another process won the race - clean up temp and succeed
|
|
142
|
-
(0, _fsremovecompat.safeRm)(tempPath, function() {
|
|
143
|
-
return cb();
|
|
144
|
-
});
|
|
93
|
+
// Folder doesn't exist - do atomic install with temp folder
|
|
94
|
+
var tempPath = (0, _tempsuffix.default)(result.installPath);
|
|
95
|
+
var queue = new _queuecb.default(1);
|
|
96
|
+
queue.defer(_mkdirpclassic.default.bind(null, options.cachePath));
|
|
97
|
+
queue.defer(_ensureDestinationParentts.default.bind(null, tempPath));
|
|
98
|
+
// Install node to temp folder
|
|
99
|
+
queue.defer(_indexts.default.bind(null, version, tempPath, options));
|
|
100
|
+
// Check and install npm to temp folder
|
|
101
|
+
// Skip npm download only if bundled npm is modern (>= 3)
|
|
102
|
+
queue.defer(function(cb) {
|
|
103
|
+
(0, _checkMissingts.default)(tempPath, options, function(err, npmMissing) {
|
|
104
|
+
if (err) {
|
|
105
|
+
cb(err);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (!~npmMissing.indexOf('npm')) {
|
|
109
|
+
// npm is present (bundled with node) - check if it's modern enough to keep
|
|
110
|
+
var dist = (0, _nodefilenametodistpaths.getDist)(version);
|
|
111
|
+
var bundledNpmMajor = dist && dist.npm ? +dist.npm.split('.')[0] : 0;
|
|
112
|
+
if (bundledNpmMajor >= 3) {
|
|
113
|
+
cb(); // npm >= 3 bundled, skip download
|
|
145
114
|
return;
|
|
146
115
|
}
|
|
147
|
-
|
|
148
|
-
|
|
116
|
+
// old npm (<3) is buggy - delete it so installNPM can override
|
|
117
|
+
var platform = options.platform;
|
|
118
|
+
var libPath = platform === 'win32' ? tempPath : _path.default.join(tempPath, 'lib');
|
|
119
|
+
var npmPath = _path.default.join(libPath, 'node_modules', 'npm');
|
|
120
|
+
(0, _fsremovecompat.safeRm)(npmPath, function() {
|
|
121
|
+
return (0, _indexts1.default)(version, tempPath, options, cb);
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
(0, _indexts1.default)(version, tempPath, options, cb);
|
|
149
126
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
127
|
+
});
|
|
128
|
+
// Atomic rename: move temp folder to final destination
|
|
129
|
+
queue.defer(function(cb) {
|
|
130
|
+
_fs.default.rename(tempPath, result.installPath, function(err) {
|
|
131
|
+
if (!err) return cb();
|
|
132
|
+
// Race condition: another process may have already created dest
|
|
133
|
+
if (err.code === 'EEXIST' || err.code === 'ENOTEMPTY' || err.code === 'EPERM') {
|
|
134
|
+
// Another process won the race - clean up temp and succeed
|
|
153
135
|
(0, _fsremovecompat.safeRm)(tempPath, function() {
|
|
154
|
-
return
|
|
136
|
+
return cb();
|
|
155
137
|
});
|
|
156
138
|
return;
|
|
157
139
|
}
|
|
158
|
-
|
|
140
|
+
cb(err);
|
|
159
141
|
});
|
|
160
142
|
});
|
|
143
|
+
queue.await(function(err) {
|
|
144
|
+
if (err) {
|
|
145
|
+
// Clean up temp folder on error
|
|
146
|
+
(0, _fsremovecompat.safeRm)(tempPath, function() {
|
|
147
|
+
return callback(err);
|
|
148
|
+
});
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
callback(null, result);
|
|
152
|
+
});
|
|
161
153
|
});
|
|
162
154
|
});
|
|
163
155
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/workers/install.ts"],"sourcesContent":["import fs from 'fs';\nimport { safeRm } from 'fs-remove-compat';\nimport isVersion from 'is-version';\nimport mkdirp from 'mkdirp-classic';\nimport { getDist } from 'node-filename-to-dist-paths';\nimport resolveVersions from 'node-resolve-versions';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport tempSuffix from 'temp-suffix';\n\nimport { DEFAULT_STORAGE_PATHS } from '../constants.ts';\n\nimport createResult from '../createResult.ts';\nimport createStoragePaths from '../createStoragePaths.ts';\nimport installNode from '../installNode/index.ts';\n\nimport installNPM from '../installNPM/index.ts';\nimport checkMissing from '../lib/checkMissing.ts';\nimport ensureDestinationParent from '../lib/ensureDestinationParent.ts';\nimport getTarget from '../lib/getTarget.ts';\n\nimport type { InstallCallback, InstallOptions } from '../types.ts';\n\ntype GetVersionsCallback = (error?: Error, results?: string[]) => undefined;\nfunction getVersions(versionExpression: string, options: InstallOptions, callback: GetVersionsCallback): undefined {\n // short circuit\n isVersion(versionExpression) ? callback(null, [versionExpression]) : resolveVersions(versionExpression, options, callback);\n}\n\nexport default function install(versionExpression: string, options: InstallOptions, callback: InstallCallback): undefined {\n const storagePaths = options.storagePath ? createStoragePaths(options.storagePath) : DEFAULT_STORAGE_PATHS;\n options = { ...storagePaths, ...options, ...getTarget(options) };\n getVersions(versionExpression, options, (err?: Error, versions?: string[]): undefined => {\n if (err) {\n callback(err);\n return;\n }\n if (!versions.length) {\n callback(new Error(`Could not resolve versions for: ${versionExpression}`));\n return;\n }\n if (versions.length !== 1) {\n callback(new Error(`Version ${versionExpression} resolved to multiple versions: ${versions.map((x) => x)}. Expecting one.`));\n return;\n }\n\n const version = versions[0];\n const result = createResult(options, version);\n\n // Fast path:
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/workers/install.ts"],"sourcesContent":["import fs from 'fs';\nimport { safeRm } from 'fs-remove-compat';\nimport isVersion from 'is-version';\nimport mkdirp from 'mkdirp-classic';\nimport { getDist } from 'node-filename-to-dist-paths';\nimport resolveVersions from 'node-resolve-versions';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport tempSuffix from 'temp-suffix';\n\nimport { DEFAULT_STORAGE_PATHS } from '../constants.ts';\n\nimport createResult from '../createResult.ts';\nimport createStoragePaths from '../createStoragePaths.ts';\nimport installNode from '../installNode/index.ts';\n\nimport installNPM from '../installNPM/index.ts';\nimport checkMissing from '../lib/checkMissing.ts';\nimport ensureDestinationParent from '../lib/ensureDestinationParent.ts';\nimport getTarget from '../lib/getTarget.ts';\n\nimport type { InstallCallback, InstallOptions } from '../types.ts';\n\ntype GetVersionsCallback = (error?: Error, results?: string[]) => undefined;\nfunction getVersions(versionExpression: string, options: InstallOptions, callback: GetVersionsCallback): undefined {\n // short circuit\n isVersion(versionExpression) ? callback(null, [versionExpression]) : resolveVersions(versionExpression, options, callback);\n}\n\nexport default function install(versionExpression: string, options: InstallOptions, callback: InstallCallback): undefined {\n const storagePaths = options.storagePath ? createStoragePaths(options.storagePath) : DEFAULT_STORAGE_PATHS;\n options = { ...storagePaths, ...options, ...getTarget(options) };\n getVersions(versionExpression, options, (err?: Error, versions?: string[]): undefined => {\n if (err) {\n callback(err);\n return;\n }\n if (!versions.length) {\n callback(new Error(`Could not resolve versions for: ${versionExpression}`));\n return;\n }\n if (versions.length !== 1) {\n callback(new Error(`Version ${versionExpression} resolved to multiple versions: ${versions.map((x) => x)}. Expecting one.`));\n return;\n }\n\n const version = versions[0];\n const result = createResult(options, version);\n\n // Fast path: with atomic installs, folder exists = complete installation\n fs.stat(result.installPath, (err) => {\n if (!err) {\n callback(null, result);\n return;\n }\n\n // Folder doesn't exist - do atomic install with temp folder\n const tempPath = tempSuffix(result.installPath);\n\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, options.cachePath));\n queue.defer(ensureDestinationParent.bind(null, tempPath));\n\n // Install node to temp folder\n queue.defer(installNode.bind(null, version, tempPath, options));\n\n // Check and install npm to temp folder\n // Skip npm download only if bundled npm is modern (>= 3)\n queue.defer((cb) => {\n checkMissing(tempPath, options, (err, npmMissing): undefined => {\n if (err) {\n cb(err);\n return;\n }\n if (!~npmMissing.indexOf('npm')) {\n // npm is present (bundled with node) - check if it's modern enough to keep\n const dist = getDist(version);\n const bundledNpmMajor = dist && dist.npm ? +dist.npm.split('.')[0] : 0;\n if (bundledNpmMajor >= 3) {\n cb(); // npm >= 3 bundled, skip download\n return;\n }\n // old npm (<3) is buggy - delete it so installNPM can override\n const platform = options.platform;\n const libPath = platform === 'win32' ? tempPath : path.join(tempPath, 'lib');\n const npmPath = path.join(libPath, 'node_modules', 'npm');\n safeRm(npmPath, () => installNPM(version, tempPath, options, cb));\n return;\n }\n installNPM(version, tempPath, options, cb);\n });\n });\n\n // Atomic rename: move temp folder to final destination\n queue.defer((cb) => {\n fs.rename(tempPath, result.installPath, (err) => {\n if (!err) return cb();\n // Race condition: another process may have already created dest\n if (err.code === 'EEXIST' || err.code === 'ENOTEMPTY' || err.code === 'EPERM') {\n // Another process won the race - clean up temp and succeed\n safeRm(tempPath, () => cb());\n return;\n }\n cb(err);\n });\n });\n\n queue.await((err) => {\n if (err) {\n // Clean up temp folder on error\n safeRm(tempPath, () => callback(err));\n return;\n }\n callback(null, result);\n });\n });\n });\n}\n"],"names":["install","getVersions","versionExpression","options","callback","isVersion","resolveVersions","storagePaths","storagePath","createStoragePaths","DEFAULT_STORAGE_PATHS","getTarget","err","versions","length","Error","map","x","version","result","createResult","fs","stat","installPath","tempPath","tempSuffix","queue","Queue","defer","mkdirp","bind","cachePath","ensureDestinationParent","installNode","cb","checkMissing","npmMissing","indexOf","dist","getDist","bundledNpmMajor","npm","split","platform","libPath","path","join","npmPath","safeRm","installNPM","rename","code","await"],"mappings":";;;;+BA6BA;;;eAAwBA;;;yDA7BT;8BACQ;gEACD;oEACH;uCACK;0EACI;2DACX;8DACC;iEACK;2BAEe;qEAEb;2EACM;8DACP;+DAED;qEACE;gFACW;kEACd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKtB,SAASC,YAAYC,iBAAyB,EAAEC,OAAuB,EAAEC,QAA6B;IACpG,gBAAgB;IAChBC,IAAAA,kBAAS,EAACH,qBAAqBE,SAAS,MAAM;QAACF;KAAkB,IAAII,IAAAA,4BAAe,EAACJ,mBAAmBC,SAASC;AACnH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AACF"}
|
package/dist/esm/cli.d.ts
CHANGED
|
File without changes
|
package/dist/esm/cli.js
CHANGED
|
File without changes
|
package/dist/esm/compat.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Compatibility Layer for Node.js 0.8+
|
|
3
3
|
* Local to this package - contains only needed functions.
|
|
4
4
|
*/ import os from 'os';
|
|
5
|
-
|
|
5
|
+
const hasHomedir = typeof os.homedir === 'function';
|
|
6
6
|
export function homedir() {
|
|
7
7
|
if (hasHomedir) {
|
|
8
8
|
return os.homedir();
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
const home = require('homedir-polyfill');
|
|
11
11
|
return home();
|
|
12
12
|
}
|
package/dist/esm/compat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\nimport os from 'os';\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\nimport os from 'os';\n\nconst hasHomedir = typeof os.homedir === 'function';\n\nexport function homedir(): string {\n if (hasHomedir) {\n return os.homedir();\n }\n const home = require('homedir-polyfill');\n return home();\n}\n"],"names":["os","hasHomedir","homedir","home","require"],"mappings":"AAAA;;;CAGC,GACD,OAAOA,QAAQ,KAAK;AAEpB,MAAMC,aAAa,OAAOD,GAAGE,OAAO,KAAK;AAEzC,OAAO,SAASA;IACd,IAAID,YAAY;QACd,OAAOD,GAAGE,OAAO;IACnB;IACA,MAAMC,OAAOC,QAAQ;IACrB,OAAOD;AACT"}
|
|
@@ -43,74 +43,66 @@ export default function install(versionExpression, options, callback) {
|
|
|
43
43
|
}
|
|
44
44
|
const version = versions[0];
|
|
45
45
|
const result = createResult(options, version);
|
|
46
|
-
// Fast path:
|
|
47
|
-
|
|
48
|
-
if (err) {
|
|
49
|
-
callback(err);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
// Early exit if both node and npm are already present
|
|
53
|
-
if (!missing.length) {
|
|
46
|
+
// Fast path: with atomic installs, folder exists = complete installation
|
|
47
|
+
fs.stat(result.installPath, (err)=>{
|
|
48
|
+
if (!err) {
|
|
54
49
|
callback(null, result);
|
|
55
50
|
return;
|
|
56
51
|
}
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (bundledNpmMajor >= 3) {
|
|
79
|
-
cb(); // npm >= 3 bundled, skip download
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
// old npm (<3) is buggy - delete it so installNPM can override
|
|
83
|
-
const platform = options.platform;
|
|
84
|
-
const libPath = platform === 'win32' ? tempPath : path.join(tempPath, 'lib');
|
|
85
|
-
const npmPath = path.join(libPath, 'node_modules', 'npm');
|
|
86
|
-
safeRm(npmPath, ()=>installNPM(version, tempPath, options, cb));
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
installNPM(version, tempPath, options, cb);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
// Atomic rename: move temp folder to final destination
|
|
93
|
-
queue.defer((cb)=>{
|
|
94
|
-
fs.rename(tempPath, result.installPath, (err)=>{
|
|
95
|
-
if (!err) return cb();
|
|
96
|
-
// Race condition: another process may have already created dest
|
|
97
|
-
if (err.code === 'EEXIST' || err.code === 'ENOTEMPTY' || err.code === 'EPERM') {
|
|
98
|
-
// Another process won the race - clean up temp and succeed
|
|
99
|
-
safeRm(tempPath, ()=>cb());
|
|
52
|
+
// Folder doesn't exist - do atomic install with temp folder
|
|
53
|
+
const tempPath = tempSuffix(result.installPath);
|
|
54
|
+
const queue = new Queue(1);
|
|
55
|
+
queue.defer(mkdirp.bind(null, options.cachePath));
|
|
56
|
+
queue.defer(ensureDestinationParent.bind(null, tempPath));
|
|
57
|
+
// Install node to temp folder
|
|
58
|
+
queue.defer(installNode.bind(null, version, tempPath, options));
|
|
59
|
+
// Check and install npm to temp folder
|
|
60
|
+
// Skip npm download only if bundled npm is modern (>= 3)
|
|
61
|
+
queue.defer((cb)=>{
|
|
62
|
+
checkMissing(tempPath, options, (err, npmMissing)=>{
|
|
63
|
+
if (err) {
|
|
64
|
+
cb(err);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (!~npmMissing.indexOf('npm')) {
|
|
68
|
+
// npm is present (bundled with node) - check if it's modern enough to keep
|
|
69
|
+
const dist = getDist(version);
|
|
70
|
+
const bundledNpmMajor = dist && dist.npm ? +dist.npm.split('.')[0] : 0;
|
|
71
|
+
if (bundledNpmMajor >= 3) {
|
|
72
|
+
cb(); // npm >= 3 bundled, skip download
|
|
100
73
|
return;
|
|
101
74
|
}
|
|
102
|
-
|
|
103
|
-
|
|
75
|
+
// old npm (<3) is buggy - delete it so installNPM can override
|
|
76
|
+
const platform = options.platform;
|
|
77
|
+
const libPath = platform === 'win32' ? tempPath : path.join(tempPath, 'lib');
|
|
78
|
+
const npmPath = path.join(libPath, 'node_modules', 'npm');
|
|
79
|
+
safeRm(npmPath, ()=>installNPM(version, tempPath, options, cb));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
installNPM(version, tempPath, options, cb);
|
|
104
83
|
});
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
84
|
+
});
|
|
85
|
+
// Atomic rename: move temp folder to final destination
|
|
86
|
+
queue.defer((cb)=>{
|
|
87
|
+
fs.rename(tempPath, result.installPath, (err)=>{
|
|
88
|
+
if (!err) return cb();
|
|
89
|
+
// Race condition: another process may have already created dest
|
|
90
|
+
if (err.code === 'EEXIST' || err.code === 'ENOTEMPTY' || err.code === 'EPERM') {
|
|
91
|
+
// Another process won the race - clean up temp and succeed
|
|
92
|
+
safeRm(tempPath, ()=>cb());
|
|
109
93
|
return;
|
|
110
94
|
}
|
|
111
|
-
|
|
95
|
+
cb(err);
|
|
112
96
|
});
|
|
113
97
|
});
|
|
98
|
+
queue.await((err)=>{
|
|
99
|
+
if (err) {
|
|
100
|
+
// Clean up temp folder on error
|
|
101
|
+
safeRm(tempPath, ()=>callback(err));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
callback(null, result);
|
|
105
|
+
});
|
|
114
106
|
});
|
|
115
107
|
});
|
|
116
108
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/workers/install.ts"],"sourcesContent":["import fs from 'fs';\nimport { safeRm } from 'fs-remove-compat';\nimport isVersion from 'is-version';\nimport mkdirp from 'mkdirp-classic';\nimport { getDist } from 'node-filename-to-dist-paths';\nimport resolveVersions from 'node-resolve-versions';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport tempSuffix from 'temp-suffix';\n\nimport { DEFAULT_STORAGE_PATHS } from '../constants.ts';\n\nimport createResult from '../createResult.ts';\nimport createStoragePaths from '../createStoragePaths.ts';\nimport installNode from '../installNode/index.ts';\n\nimport installNPM from '../installNPM/index.ts';\nimport checkMissing from '../lib/checkMissing.ts';\nimport ensureDestinationParent from '../lib/ensureDestinationParent.ts';\nimport getTarget from '../lib/getTarget.ts';\n\nimport type { InstallCallback, InstallOptions } from '../types.ts';\n\ntype GetVersionsCallback = (error?: Error, results?: string[]) => undefined;\nfunction getVersions(versionExpression: string, options: InstallOptions, callback: GetVersionsCallback): undefined {\n // short circuit\n isVersion(versionExpression) ? callback(null, [versionExpression]) : resolveVersions(versionExpression, options, callback);\n}\n\nexport default function install(versionExpression: string, options: InstallOptions, callback: InstallCallback): undefined {\n const storagePaths = options.storagePath ? createStoragePaths(options.storagePath) : DEFAULT_STORAGE_PATHS;\n options = { ...storagePaths, ...options, ...getTarget(options) };\n getVersions(versionExpression, options, (err?: Error, versions?: string[]): undefined => {\n if (err) {\n callback(err);\n return;\n }\n if (!versions.length) {\n callback(new Error(`Could not resolve versions for: ${versionExpression}`));\n return;\n }\n if (versions.length !== 1) {\n callback(new Error(`Version ${versionExpression} resolved to multiple versions: ${versions.map((x) => x)}. Expecting one.`));\n return;\n }\n\n const version = versions[0];\n const result = createResult(options, version);\n\n // Fast path:
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/workers/install.ts"],"sourcesContent":["import fs from 'fs';\nimport { safeRm } from 'fs-remove-compat';\nimport isVersion from 'is-version';\nimport mkdirp from 'mkdirp-classic';\nimport { getDist } from 'node-filename-to-dist-paths';\nimport resolveVersions from 'node-resolve-versions';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport tempSuffix from 'temp-suffix';\n\nimport { DEFAULT_STORAGE_PATHS } from '../constants.ts';\n\nimport createResult from '../createResult.ts';\nimport createStoragePaths from '../createStoragePaths.ts';\nimport installNode from '../installNode/index.ts';\n\nimport installNPM from '../installNPM/index.ts';\nimport checkMissing from '../lib/checkMissing.ts';\nimport ensureDestinationParent from '../lib/ensureDestinationParent.ts';\nimport getTarget from '../lib/getTarget.ts';\n\nimport type { InstallCallback, InstallOptions } from '../types.ts';\n\ntype GetVersionsCallback = (error?: Error, results?: string[]) => undefined;\nfunction getVersions(versionExpression: string, options: InstallOptions, callback: GetVersionsCallback): undefined {\n // short circuit\n isVersion(versionExpression) ? callback(null, [versionExpression]) : resolveVersions(versionExpression, options, callback);\n}\n\nexport default function install(versionExpression: string, options: InstallOptions, callback: InstallCallback): undefined {\n const storagePaths = options.storagePath ? createStoragePaths(options.storagePath) : DEFAULT_STORAGE_PATHS;\n options = { ...storagePaths, ...options, ...getTarget(options) };\n getVersions(versionExpression, options, (err?: Error, versions?: string[]): undefined => {\n if (err) {\n callback(err);\n return;\n }\n if (!versions.length) {\n callback(new Error(`Could not resolve versions for: ${versionExpression}`));\n return;\n }\n if (versions.length !== 1) {\n callback(new Error(`Version ${versionExpression} resolved to multiple versions: ${versions.map((x) => x)}. Expecting one.`));\n return;\n }\n\n const version = versions[0];\n const result = createResult(options, version);\n\n // Fast path: with atomic installs, folder exists = complete installation\n fs.stat(result.installPath, (err) => {\n if (!err) {\n callback(null, result);\n return;\n }\n\n // Folder doesn't exist - do atomic install with temp folder\n const tempPath = tempSuffix(result.installPath);\n\n const queue = new Queue(1);\n queue.defer(mkdirp.bind(null, options.cachePath));\n queue.defer(ensureDestinationParent.bind(null, tempPath));\n\n // Install node to temp folder\n queue.defer(installNode.bind(null, version, tempPath, options));\n\n // Check and install npm to temp folder\n // Skip npm download only if bundled npm is modern (>= 3)\n queue.defer((cb) => {\n checkMissing(tempPath, options, (err, npmMissing): undefined => {\n if (err) {\n cb(err);\n return;\n }\n if (!~npmMissing.indexOf('npm')) {\n // npm is present (bundled with node) - check if it's modern enough to keep\n const dist = getDist(version);\n const bundledNpmMajor = dist && dist.npm ? +dist.npm.split('.')[0] : 0;\n if (bundledNpmMajor >= 3) {\n cb(); // npm >= 3 bundled, skip download\n return;\n }\n // old npm (<3) is buggy - delete it so installNPM can override\n const platform = options.platform;\n const libPath = platform === 'win32' ? tempPath : path.join(tempPath, 'lib');\n const npmPath = path.join(libPath, 'node_modules', 'npm');\n safeRm(npmPath, () => installNPM(version, tempPath, options, cb));\n return;\n }\n installNPM(version, tempPath, options, cb);\n });\n });\n\n // Atomic rename: move temp folder to final destination\n queue.defer((cb) => {\n fs.rename(tempPath, result.installPath, (err) => {\n if (!err) return cb();\n // Race condition: another process may have already created dest\n if (err.code === 'EEXIST' || err.code === 'ENOTEMPTY' || err.code === 'EPERM') {\n // Another process won the race - clean up temp and succeed\n safeRm(tempPath, () => cb());\n return;\n }\n cb(err);\n });\n });\n\n queue.await((err) => {\n if (err) {\n // Clean up temp folder on error\n safeRm(tempPath, () => callback(err));\n return;\n }\n callback(null, result);\n });\n });\n });\n}\n"],"names":["fs","safeRm","isVersion","mkdirp","getDist","resolveVersions","path","Queue","tempSuffix","DEFAULT_STORAGE_PATHS","createResult","createStoragePaths","installNode","installNPM","checkMissing","ensureDestinationParent","getTarget","getVersions","versionExpression","options","callback","install","storagePaths","storagePath","err","versions","length","Error","map","x","version","result","stat","installPath","tempPath","queue","defer","bind","cachePath","cb","npmMissing","indexOf","dist","bundledNpmMajor","npm","split","platform","libPath","join","npmPath","rename","code","await"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,eAAe,aAAa;AACnC,OAAOC,YAAY,iBAAiB;AACpC,SAASC,OAAO,QAAQ,8BAA8B;AACtD,OAAOC,qBAAqB,wBAAwB;AACpD,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,OAAOC,gBAAgB,cAAc;AAErC,SAASC,qBAAqB,QAAQ,kBAAkB;AAExD,OAAOC,kBAAkB,qBAAqB;AAC9C,OAAOC,wBAAwB,2BAA2B;AAC1D,OAAOC,iBAAiB,0BAA0B;AAElD,OAAOC,gBAAgB,yBAAyB;AAChD,OAAOC,kBAAkB,yBAAyB;AAClD,OAAOC,6BAA6B,oCAAoC;AACxE,OAAOC,eAAe,sBAAsB;AAK5C,SAASC,YAAYC,iBAAyB,EAAEC,OAAuB,EAAEC,QAA6B;IACpG,gBAAgB;IAChBlB,UAAUgB,qBAAqBE,SAAS,MAAM;QAACF;KAAkB,IAAIb,gBAAgBa,mBAAmBC,SAASC;AACnH;AAEA,eAAe,SAASC,QAAQH,iBAAyB,EAAEC,OAAuB,EAAEC,QAAyB;IAC3G,MAAME,eAAeH,QAAQI,WAAW,GAAGZ,mBAAmBQ,QAAQI,WAAW,IAAId;IACrFU,UAAU;QAAE,GAAGG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AAG,CAACF,KAAKE,GAAG,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG;wBACrE,IAAIF,mBAAmB,GAAG;4BACxBJ,MAAM,kCAAkC;4BACxC;wBACF;wBACA,+DAA+D;wBAC/D,MAAMO,WAAW3B,QAAQ2B,QAAQ;wBACjC,MAAMC,UAAUD,aAAa,UAAUZ,WAAW5B,KAAK0C,IAAI,CAACd,UAAU;wBACtE,MAAMe,UAAU3C,KAAK0C,IAAI,CAACD,SAAS,gBAAgB;wBACnD9C,OAAOgD,SAAS,IAAMpC,WAAWiB,SAASI,UAAUf,SAASoB;wBAC7D;oBACF;oBACA1B,WAAWiB,SAASI,UAAUf,SAASoB;gBACzC;YACF;YAEA,uDAAuD;YACvDJ,MAAMC,KAAK,CAAC,CAACG;gBACXvC,GAAGkD,MAAM,CAAChB,UAAUH,OAAOE,WAAW,EAAE,CAACT;oBACvC,IAAI,CAACA,KAAK,OAAOe;oBACjB,gEAAgE;oBAChE,IAAIf,IAAI2B,IAAI,KAAK,YAAY3B,IAAI2B,IAAI,KAAK,eAAe3B,IAAI2B,IAAI,KAAK,SAAS;wBAC7E,2DAA2D;wBAC3DlD,OAAOiC,UAAU,IAAMK;wBACvB;oBACF;oBACAA,GAAGf;gBACL;YACF;YAEAW,MAAMiB,KAAK,CAAC,CAAC5B;gBACX,IAAIA,KAAK;oBACP,gCAAgC;oBAChCvB,OAAOiC,UAAU,IAAMd,SAASI;oBAChC;gBACF;gBACAJ,SAAS,MAAMW;YACjB;QACF;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-install-release",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.3",
|
|
4
4
|
"description": "Cross-platform solution for installing releases of Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node",
|
|
@@ -43,23 +43,23 @@
|
|
|
43
43
|
"version": "tsds version"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"cpu-arch": "^1.0.
|
|
47
|
-
"cross-spawn-cb": "^2.4.
|
|
48
|
-
"exit-compat": "^1.0.
|
|
49
|
-
"fast-extract": "^1.8.
|
|
50
|
-
"fs-copy-compat": "^0.1.
|
|
51
|
-
"fs-remove-compat": "^0.2.
|
|
52
|
-
"get-remote": "^2.3.
|
|
46
|
+
"cpu-arch": "^1.0.8",
|
|
47
|
+
"cross-spawn-cb": "^2.4.14",
|
|
48
|
+
"exit-compat": "^1.0.3",
|
|
49
|
+
"fast-extract": "^1.8.16",
|
|
50
|
+
"fs-copy-compat": "^0.1.5",
|
|
51
|
+
"fs-remove-compat": "^0.2.3",
|
|
52
|
+
"get-remote": "^2.3.3",
|
|
53
53
|
"getopts-compat": "^2.2.6",
|
|
54
54
|
"homedir-polyfill": "^1.0.3",
|
|
55
|
-
"is-version": "^1.0.
|
|
55
|
+
"is-version": "^1.0.9",
|
|
56
56
|
"lodash.keys": "^4.2.0",
|
|
57
57
|
"mkdirp-classic": "^0.5.3",
|
|
58
|
-
"node-filename-to-dist-paths": "^1.3.
|
|
58
|
+
"node-filename-to-dist-paths": "^1.3.14",
|
|
59
59
|
"node-resolve-versions": "^1.3.11",
|
|
60
|
-
"on-one": "^1.0.
|
|
61
|
-
"queue-cb": "^1.6.
|
|
62
|
-
"temp-suffix": "^1.0.
|
|
60
|
+
"on-one": "^1.0.10",
|
|
61
|
+
"queue-cb": "^1.6.3",
|
|
62
|
+
"temp-suffix": "^1.0.10"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/mocha": "^10.0.10",
|
|
@@ -68,11 +68,11 @@
|
|
|
68
68
|
"lodash.find": "^4.6.0",
|
|
69
69
|
"lodash.values": "^4.3.0",
|
|
70
70
|
"node-version-compare": "^1.0.3",
|
|
71
|
-
"node-version-use": "^2.1.
|
|
72
|
-
"node-version-utils": "^1.3.
|
|
71
|
+
"node-version-use": "^2.1.5",
|
|
72
|
+
"node-version-utils": "^1.3.17",
|
|
73
73
|
"pinkie-promise": "^2.0.1",
|
|
74
74
|
"ts-dev-stack": "^1.21.3",
|
|
75
|
-
"tsds-config": "^0.2.
|
|
75
|
+
"tsds-config": "^0.2.1"
|
|
76
76
|
},
|
|
77
77
|
"engines": {
|
|
78
78
|
"node": ">=0.8"
|