node-install-release 1.16.5 → 1.17.0

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.
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "default", {
10
10
  });
11
11
  var _crypto = /*#__PURE__*/ _interop_require_default(require("crypto"));
12
12
  var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
13
- var _getremote = /*#__PURE__*/ _interop_require_default(require("get-remote"));
13
+ var _getfilecompat = require("get-file-compat");
14
14
  var _nodefilenametodistpaths = require("node-filename-to-dist-paths");
15
15
  var _onone = /*#__PURE__*/ _interop_require_default(require("on-one"));
16
16
  var _path = /*#__PURE__*/ _interop_require_default(require("path"));
@@ -46,25 +46,29 @@ function installLib(version, dest, options, callback) {
46
46
  var dist = (0, _nodefilenametodistpaths.getDist)(version);
47
47
  var npmMajorPair = dist && dist.npm ? +dist.npm.split('.')[0] : _constantsts.NPM_MIN_VERSION;
48
48
  var npmMajor = Math.max(npmMajorPair, _constantsts.NPM_MIN_VERSION);
49
- (0, _getremote.default)(_constantsts.NPM_DIST_TAGS_URL).json(function(err, res) {
49
+ (0, _getfilecompat.getContent)(_constantsts.NPM_DIST_TAGS_URL, 'utf8', function(err, res) {
50
50
  if (err) return callback(err);
51
- var distTags = res.body;
52
- var npmVersion = distTags["latest-".concat(npmMajor)] || distTags["next-".concat(npmMajor)] || distTags.latest;
53
- var downloadPath = "".concat(_constantsts.NPM_DIST_URL, "/-/npm-").concat(npmVersion, ".tgz");
54
- var cachePath = _path.default.join(options.cachePath, _path.default.basename(downloadPath));
55
- var checksum;
56
- var queue = new _queuecb.default(1);
57
- queue.defer(_conditionalCachets.default.bind(null, downloadPath, cachePath));
58
- queue.defer(function(cb) {
59
- calculateChecksum(cachePath, function(err, hash) {
60
- checksum = hash;
61
- cb(err);
51
+ try {
52
+ var distTags = JSON.parse(res.content);
53
+ var npmVersion = distTags["latest-".concat(npmMajor)] || distTags["next-".concat(npmMajor)] || distTags.latest;
54
+ var downloadPath = "".concat(_constantsts.NPM_DIST_URL, "/-/npm-").concat(npmVersion, ".tgz");
55
+ var cachePath = _path.default.join(options.cachePath, _path.default.basename(downloadPath));
56
+ var checksum;
57
+ var queue = new _queuecb.default(1);
58
+ queue.defer(_conditionalCachets.default.bind(null, downloadPath, cachePath));
59
+ queue.defer(function(cb) {
60
+ calculateChecksum(cachePath, function(err, hash) {
61
+ checksum = hash;
62
+ cb(err);
63
+ });
62
64
  });
63
- });
64
- queue.defer(_extractts.default.bind(null, cachePath, installPath));
65
- queue.await(function(err) {
66
- err ? callback(err) : callback(null, npmVersion, checksum);
67
- });
65
+ queue.defer(_extractts.default.bind(null, cachePath, installPath));
66
+ queue.await(function(err) {
67
+ err ? callback(err) : callback(null, npmVersion, checksum);
68
+ });
69
+ } catch (_e) {
70
+ return callback(new Error('Failed to parse npm dist-tags'));
71
+ }
68
72
  });
69
73
  }
70
74
  /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/installNPM/installLib.ts"],"sourcesContent":["import crypto from 'crypto';\nimport fs from 'fs';\nimport get from 'get-remote';\nimport { getDist } from 'node-filename-to-dist-paths';\nimport oo from 'on-one';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport { NPM_DIST_TAGS_URL, NPM_DIST_URL, NPM_MIN_VERSION } from '../constants.ts';\nimport conditionalCache from '../lib/conditionalCache.ts';\nimport extract from '../lib/extract.ts';\n\ninterface DistRecord {\n latest: string;\n}\n\nimport type { InstallOptions } from '../types.ts';\n\nexport type Callback = (error?: Error, npmVersion?: string, checksum?: string) => undefined;\n\nfunction calculateChecksum(filePath: string, callback: (err?: Error, checksum?: string) => void): void {\n const hash = crypto.createHash('sha256');\n const stream = fs.createReadStream(filePath);\n stream.on('data', (data) => hash.update(data));\n oo(stream, ['error', 'end', 'close', 'finish'], (err?: Error) => {\n if (err) return callback(err);\n callback(null, hash.digest('hex'));\n });\n}\n\nexport default function installLib(version: string, dest: string, options: InstallOptions, callback: Callback): undefined {\n const platform = options.platform;\n const libPath = platform === 'win32' ? dest : path.join(dest, 'lib');\n const installPath = path.join(libPath, 'node_modules', 'npm');\n\n const dist = getDist(version);\n const npmMajorPair = dist && dist.npm ? +dist.npm.split('.')[0] : NPM_MIN_VERSION;\n const npmMajor = Math.max(npmMajorPair, NPM_MIN_VERSION);\n\n get(NPM_DIST_TAGS_URL).json((err, res) => {\n if (err) return callback(err);\n const distTags = res.body as DistRecord;\n const npmVersion = distTags[`latest-${npmMajor}`] || distTags[`next-${npmMajor}`] || distTags.latest;\n const downloadPath = `${NPM_DIST_URL}/-/npm-${npmVersion}.tgz`;\n const cachePath = path.join(options.cachePath, path.basename(downloadPath));\n\n let checksum: string | undefined;\n const queue = new Queue(1);\n queue.defer(conditionalCache.bind(null, downloadPath, cachePath));\n queue.defer((cb) => {\n calculateChecksum(cachePath, (err, hash) => {\n checksum = hash;\n cb(err);\n });\n });\n queue.defer(extract.bind(null, cachePath, installPath));\n queue.await((err) => {\n err ? callback(err) : callback(null, npmVersion, checksum);\n });\n });\n}\n"],"names":["installLib","calculateChecksum","filePath","callback","hash","crypto","createHash","stream","fs","createReadStream","on","data","update","oo","err","digest","version","dest","options","platform","libPath","path","join","installPath","dist","getDist","npmMajorPair","npm","split","NPM_MIN_VERSION","npmMajor","Math","max","get","NPM_DIST_TAGS_URL","json","res","distTags","body","npmVersion","latest","downloadPath","NPM_DIST_URL","cachePath","basename","checksum","queue","Queue","defer","conditionalCache","bind","cb","extract","await"],"mappings":";;;;+BA6BA;;;eAAwBA;;;6DA7BL;yDACJ;gEACC;uCACQ;4DACT;2DACE;8DACC;2BAC+C;yEACpC;gEACT;;;;;;AAUpB,SAASC,kBAAkBC,QAAgB,EAAEC,QAAkD;IAC7F,IAA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AIC,gBAAK,CAAC;QACxBD,MAAME,KAAK,CAACC,2BAAgB,CAACC,IAAI,CAAC,MAAMT,cAAcE;QACtDG,MAAME,KAAK,CAAC,SAACG;YACXlD,kBAAkB0C,WAAW,SAAC7B,KAAKV;gBACjCyC,WAAWzC;gBACX+C,GAAGrC;YACL;QACF;QACAgC,MAAME,KAAK,CAACI,kBAAO,CAACF,IAAI,CAAC,MAAMP,WAAWpB;QAC1CuB,MAAMO,KAAK,CAAC,SAACvC;YACXA,MAAMX,SAASW,OAAOX,SAAS,MAAMoC,YAAYM;QACnD;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/installNPM/installLib.ts"],"sourcesContent":["import crypto from 'crypto';\nimport fs from 'fs';\nimport { getContent } from 'get-file-compat';\nimport { getDist } from 'node-filename-to-dist-paths';\nimport oo from 'on-one';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport { NPM_DIST_TAGS_URL, NPM_DIST_URL, NPM_MIN_VERSION } from '../constants.ts';\nimport conditionalCache from '../lib/conditionalCache.ts';\nimport extract from '../lib/extract.ts';\n\ninterface DistRecord {\n latest: string;\n}\n\nimport type { InstallOptions } from '../types.ts';\n\nexport type Callback = (error?: Error, npmVersion?: string, checksum?: string) => undefined;\n\nfunction calculateChecksum(filePath: string, callback: (err?: Error, checksum?: string) => void): void {\n const hash = crypto.createHash('sha256');\n const stream = fs.createReadStream(filePath);\n stream.on('data', (data) => hash.update(data));\n oo(stream, ['error', 'end', 'close', 'finish'], (err?: Error) => {\n if (err) return callback(err);\n callback(null, hash.digest('hex'));\n });\n}\n\nexport default function installLib(version: string, dest: string, options: InstallOptions, callback: Callback): undefined {\n const platform = options.platform;\n const libPath = platform === 'win32' ? dest : path.join(dest, 'lib');\n const installPath = path.join(libPath, 'node_modules', 'npm');\n\n const dist = getDist(version);\n const npmMajorPair = dist && dist.npm ? +dist.npm.split('.')[0] : NPM_MIN_VERSION;\n const npmMajor = Math.max(npmMajorPair, NPM_MIN_VERSION);\n\n getContent(NPM_DIST_TAGS_URL, 'utf8', (err, res) => {\n if (err) return callback(err);\n try {\n const distTags = JSON.parse(res.content) as DistRecord;\n const npmVersion = distTags[`latest-${npmMajor}`] || distTags[`next-${npmMajor}`] || distTags.latest;\n const downloadPath = `${NPM_DIST_URL}/-/npm-${npmVersion}.tgz`;\n const cachePath = path.join(options.cachePath, path.basename(downloadPath));\n\n let checksum: string | undefined;\n const queue = new Queue(1);\n queue.defer(conditionalCache.bind(null, downloadPath, cachePath));\n queue.defer((cb) => {\n calculateChecksum(cachePath, (err, hash) => {\n checksum = hash;\n cb(err);\n });\n });\n queue.defer(extract.bind(null, cachePath, installPath));\n queue.await((err) => {\n err ? callback(err) : callback(null, npmVersion, checksum);\n });\n } catch (_e) {\n return callback(new Error('Failed to parse npm dist-tags'));\n }\n });\n}\n"],"names":["installLib","calculateChecksum","filePath","callback","hash","crypto","createHash","stream","fs","createReadStream","on","data","update","oo","err","digest","version","dest","options","platform","libPath","path","join","installPath","dist","getDist","npmMajorPair","npm","split","NPM_MIN_VERSION","npmMajor","Math","max","getContent","NPM_DIST_TAGS_URL","res","distTags","JSON","parse","content","npmVersion","latest","downloadPath","NPM_DIST_URL","cachePath","basename","checksum","queue","Queue","defer","conditionalCache","bind","cb","extract","await","_e","Error"],"mappings":";;;;+BA6BA;;;eAAwBA;;;6DA7BL;yDACJ;6BACY;uCACH;4DACT;2DACE;8DACC;2BAC+C;yEACpC;gEACT;;;;;;AAUpB,SAASC,kBAAkBC,QAAgB,EAAEC,QAAkD;IAC7F,IAAMC,OAAOC,eAAM,CAACC,UAAU,CAAC;IAC/B,IAAMC,SAASC,WAAE,CAACC,gBAAgB,CAACP;IACnCK,OAAOG,EAAE,CAAC,QAAQ,SAACC;eAASP,KAAKQ,MAAM,CAACD;;IACxCE,IAAAA,cAAE,EAACN,QAAQ;QAAC;QAAS;QAAO;QAAS;KAAS,EAAE,SAACO;QAC/C,IAAIA,KAAK,OAAOX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ACI,kBAAO,CAACF,IAAI,CAAC,MAAMP,WAAWrB;YAC1CwB,MAAMO,KAAK,CAAC,SAACxC;gBACXA,MAAMX,SAASW,OAAOX,SAAS,MAAMqC,YAAYM;YACnD;QACF,EAAE,OAAOS,IAAI;YACX,OAAOpD,SAAS,IAAIqD,MAAM;QAC5B;IACF;AACF"}
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "default", {
10
10
  });
11
11
  var _crypto = /*#__PURE__*/ _interop_require_default(require("crypto"));
12
12
  var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
13
- var _getremote = /*#__PURE__*/ _interop_require_default(require("get-remote"));
13
+ var _getfilecompat = require("get-file-compat");
14
14
  var _onone = /*#__PURE__*/ _interop_require_default(require("on-one"));
15
15
  var _constantsts = require("../constants.js");
16
16
  function _interop_require_default(obj) {
@@ -21,9 +21,9 @@ function _interop_require_default(obj) {
21
21
  function validateDownload(distPath, installPath, callback) {
22
22
  var version = distPath.split('/')[0];
23
23
  var downloadPath = "".concat(_constantsts.NODE_DIST_BASE_URL, "/").concat(version, "/SHASUMS256.txt");
24
- (0, _getremote.default)(downloadPath).text(function(err, res) {
24
+ (0, _getfilecompat.getContent)(downloadPath, 'utf8', function(err, res) {
25
25
  if (err) return callback(err);
26
- var text = res.body;
26
+ var text = res.content;
27
27
  var filename = distPath.split('/').slice(1).join('/');
28
28
  var expected = text.split(filename)[0].split('\n').pop().trim();
29
29
  var hash = _crypto.default.createHash('sha256');
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/installNode/validateDownload.ts"],"sourcesContent":["import crypto from 'crypto';\nimport fs from 'fs';\nimport get from 'get-remote';\nimport oo from 'on-one';\nimport { NODE_DIST_BASE_URL } from '../constants.ts';\n\nimport type { ChecksumCallback, ChecksumResult } from '../types.ts';\n\nexport default function validateDownload(distPath: string, installPath: string, callback: ChecksumCallback): undefined {\n const version = distPath.split('/')[0];\n const downloadPath = `${NODE_DIST_BASE_URL}/${version}/SHASUMS256.txt`;\n get(downloadPath).text((err, res) => {\n if (err) return callback(err);\n const text = res.body;\n const filename = distPath.split('/').slice(1).join('/');\n const expected = text.split(filename)[0].split('\\n').pop().trim();\n const hash = crypto.createHash('sha256');\n const stream = fs.createReadStream(installPath);\n stream.on('data', (data) => hash.update(data));\n oo(stream, ['error', 'end', 'close', 'finish'], (err?: Error) => {\n if (err) {\n callback(err);\n return;\n }\n const actual = hash.digest('hex');\n const match = actual === expected;\n const checksum: ChecksumResult = { actual, expected, match };\n match ? callback(null, checksum) : callback(new Error(`${filename} checksum failed`), checksum);\n });\n });\n}\n"],"names":["validateDownload","distPath","installPath","callback","version","split","downloadPath","NODE_DIST_BASE_URL","get","text","err","res","body","filename","slice","join","expected","pop","trim","hash","crypto","createHash","stream","fs","createReadStream","on","data","update","oo","actual","digest","match","checksum","Error"],"mappings":";;;;+BAQA;;;eAAwBA;;;6DARL;yDACJ;gEACC;4DACD;2BACoB;;;;;;AAIpB,SAASA,iBAAiBC,QAAgB,EAAEC,WAAmB,EAAEC,QAA0B;IACxG,IAAMC,UAAUH,SAASI,KAAK,CAAC,IAAI,CAAC,EAAE;IACtC,IAAMC,eAAe,AAAC,GAAwBF,OAAtBG,+BAAkB,EAAC,KAAW,OAARH,SAAQ;IACtDI,IAAAA,kBAAG,EAACF,cAAcG,IAAI,CAAC,SAACC,KAAKC;QAC3B,IAAID,KAAK,OAAOP,SAASO;QACzB,IAAMD,OAAOE,IAAIC,IAAI;QACrB,IAAMC,WAAWZ,SAASI,KAAK,CAAC,KAAKS,KAAK,CAAC,GAAGC,IAAI,CAAC;QACnD,IAAMC,WAAWP,KAAKJ,KAAK,CAACQ,SAAS,CAAC,EAAE,CAACR,KAAK,CAAC,MAAMY,GAAG,GAAGC,IAAI;QAC/D,IAAMC,OAAOC,eAAM,CAACC,UAAU,CAAC;QAC/B,IAAMC,SAASC,WAAE,CAACC,gBAAgB,CAACtB;QACnCoB,OAAOG,EAAE,CAAC,QAAQ,SAACC;mBAASP,KAAKQ,MAAM,CAACD;;QACxCE,IAAAA,cAAE,EAACN,QAAQ;YAAC;YAAS;YAAO;YAAS;SAAS,EAAE,SAACZ;YAC/C,IAAIA,KAAK;gBACPP,SAASO;gBACT;YACF;YACA,IAAMmB,SAASV,KAAKW,MAAM,CAAC;YAC3B,IAAMC,QAAQF,WAAWb;YACzB,IAAMgB,WAA2B;gBAAEH,QAAAA;gBAAQb,UAAAA;gBAAUe,OAAAA;YAAM;YAC3DA,QAAQ5B,SAAS,MAAM6B,YAAY7B,SAAS,IAAI8B,MAAM,AAAC,GAAW,OAATpB,UAAS,sBAAoBmB;QACxF;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/installNode/validateDownload.ts"],"sourcesContent":["import crypto from 'crypto';\nimport fs from 'fs';\nimport { getContent } from 'get-file-compat';\nimport oo from 'on-one';\nimport { NODE_DIST_BASE_URL } from '../constants.ts';\n\nimport type { ChecksumCallback, ChecksumResult } from '../types.ts';\n\nexport default function validateDownload(distPath: string, installPath: string, callback: ChecksumCallback): undefined {\n const version = distPath.split('/')[0];\n const downloadPath = `${NODE_DIST_BASE_URL}/${version}/SHASUMS256.txt`;\n getContent(downloadPath, 'utf8', (err, res) => {\n if (err) return callback(err);\n const text = res.content;\n const filename = distPath.split('/').slice(1).join('/');\n const expected = text.split(filename)[0].split('\\n').pop().trim();\n const hash = crypto.createHash('sha256');\n const stream = fs.createReadStream(installPath);\n stream.on('data', (data) => hash.update(data));\n oo(stream, ['error', 'end', 'close', 'finish'], (err?: Error) => {\n if (err) {\n callback(err);\n return;\n }\n const actual = hash.digest('hex');\n const match = actual === expected;\n const checksum: ChecksumResult = { actual, expected, match };\n match ? callback(null, checksum) : callback(new Error(`${filename} checksum failed`), checksum);\n });\n });\n}\n"],"names":["validateDownload","distPath","installPath","callback","version","split","downloadPath","NODE_DIST_BASE_URL","getContent","err","res","text","content","filename","slice","join","expected","pop","trim","hash","crypto","createHash","stream","fs","createReadStream","on","data","update","oo","actual","digest","match","checksum","Error"],"mappings":";;;;+BAQA;;;eAAwBA;;;6DARL;yDACJ;6BACY;4DACZ;2BACoB;;;;;;AAIpB,SAASA,iBAAiBC,QAAgB,EAAEC,WAAmB,EAAEC,QAA0B;IACxG,IAAMC,UAAUH,SAASI,KAAK,CAAC,IAAI,CAAC,EAAE;IACtC,IAAMC,eAAe,AAAC,GAAwBF,OAAtBG,+BAAkB,EAAC,KAAW,OAARH,SAAQ;IACtDI,IAAAA,yBAAU,EAACF,cAAc,QAAQ,SAACG,KAAKC;QACrC,IAAID,KAAK,OAAON,SAASM;QACzB,IAAME,OAAOD,IAAIE,OAAO;QACxB,IAAMC,WAAWZ,SAASI,KAAK,CAAC,KAAKS,KAAK,CAAC,GAAGC,IAAI,CAAC;QACnD,IAAMC,WAAWL,KAAKN,KAAK,CAACQ,SAAS,CAAC,EAAE,CAACR,KAAK,CAAC,MAAMY,GAAG,GAAGC,IAAI;QAC/D,IAAMC,OAAOC,eAAM,CAACC,UAAU,CAAC;QAC/B,IAAMC,SAASC,WAAE,CAACC,gBAAgB,CAACtB;QACnCoB,OAAOG,EAAE,CAAC,QAAQ,SAACC;mBAASP,KAAKQ,MAAM,CAACD;;QACxCE,IAAAA,cAAE,EAACN,QAAQ;YAAC;YAAS;YAAO;YAAS;SAAS,EAAE,SAACb;YAC/C,IAAIA,KAAK;gBACPN,SAASM;gBACT;YACF;YACA,IAAMoB,SAASV,KAAKW,MAAM,CAAC;YAC3B,IAAMC,QAAQF,WAAWb;YACzB,IAAMgB,WAA2B;gBAAEH,QAAAA;gBAAQb,UAAAA;gBAAUe,OAAAA;YAAM;YAC3DA,QAAQ5B,SAAS,MAAM6B,YAAY7B,SAAS,IAAI8B,MAAM,AAAC,GAAW,OAATpB,UAAS,sBAAoBmB;QACxF;IACF;AACF"}
@@ -9,8 +9,7 @@ Object.defineProperty(exports, "default", {
9
9
  }
10
10
  });
11
11
  var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
12
- var _getremote = /*#__PURE__*/ _interop_require_default(require("get-remote"));
13
- var _path = /*#__PURE__*/ _interop_require_default(require("path"));
12
+ var _getfilecompat = require("get-file-compat");
14
13
  var _ensureDestinationParentts = /*#__PURE__*/ _interop_require_default(require("./ensureDestinationParent.js"));
15
14
  function _interop_require_default(obj) {
16
15
  return obj && obj.__esModule ? obj : {
@@ -27,10 +26,7 @@ function conditionalCache(endpoint, dest, options, callback) {
27
26
  if (!err) return callback(); // already exists
28
27
  (0, _ensureDestinationParentts.default)(dest, function(err) {
29
28
  if (err) return callback(err);
30
- (0, _getremote.default)(endpoint, {
31
- filename: _path.default.basename(dest),
32
- time: 1000
33
- }).file(_path.default.dirname(dest), callback);
29
+ (0, _getfilecompat.getFile)(endpoint, dest, callback);
34
30
  });
35
31
  });
36
32
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/lib/conditionalCache.ts"],"sourcesContent":["import fs from 'fs';\nimport get from 'get-remote';\nimport path from 'path';\nimport type { InstallOptions, NoParamCallback } from '../types.ts';\nimport ensureDestinationParent from './ensureDestinationParent.ts';\n\nexport default function conditionalCache(endpoint: string, dest: string, options: InstallOptions, callback?: NoParamCallback): undefined {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n options = options || {};\n\n fs.stat(dest, (err) => {\n if (!err) return callback(); // already exists\n\n ensureDestinationParent(dest, (err) => {\n if (err) return callback(err);\n get(endpoint, { filename: path.basename(dest), time: 1000 }).file(path.dirname(dest), callback);\n });\n });\n}\n"],"names":["conditionalCache","endpoint","dest","options","callback","fs","stat","err","ensureDestinationParent","get","filename","path","basename","time","file","dirname"],"mappings":";;;;+BAMA;;;eAAwBA;;;yDANT;gEACC;2DACC;gFAEmB;;;;;;AAErB,SAASA,iBAAiBC,QAAgB,EAAEC,IAAY,EAAEC,OAAuB,EAAEC,QAA0B;IAC1H,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU;IACZ;IACAA,UAAUA,WAAW,CAAC;IAEtBE,WAAE,CAACC,IAAI,CAACJ,MAAM,SAACK;QACb,IAAI,CAACA,KAAK,OAAOH,YAAY,iBAAiB;QAE9CI,IAAAA,kCAAuB,EAACN,MAAM,SAACK;YAC7B,IAAIA,KAAK,OAAOH,SAASG;YACzBE,IAAAA,kBAAG,EAACR,UAAU;gBAAES,UAAUC,aAAI,CAACC,QAAQ,CAACV;gBAAOW,MAAM;YAAK,GAAGC,IAAI,CAACH,aAAI,CAACI,OAAO,CAACb,OAAOE;QACxF;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/lib/conditionalCache.ts"],"sourcesContent":["import fs from 'fs';\nimport { getFile } from 'get-file-compat';\nimport type { InstallOptions, NoParamCallback } from '../types.ts';\nimport ensureDestinationParent from './ensureDestinationParent.ts';\n\nexport default function conditionalCache(endpoint: string, dest: string, options: InstallOptions, callback?: NoParamCallback): undefined {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n options = options || {};\n\n fs.stat(dest, (err) => {\n if (!err) return callback(); // already exists\n\n ensureDestinationParent(dest, (err) => {\n if (err) return callback(err);\n getFile(endpoint, dest, callback);\n });\n });\n}\n"],"names":["conditionalCache","endpoint","dest","options","callback","fs","stat","err","ensureDestinationParent","getFile"],"mappings":";;;;+BAKA;;;eAAwBA;;;yDALT;6BACS;gFAEY;;;;;;AAErB,SAASA,iBAAiBC,QAAgB,EAAEC,IAAY,EAAEC,OAAuB,EAAEC,QAA0B;IAC1H,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU;IACZ;IACAA,UAAUA,WAAW,CAAC;IAEtBE,WAAE,CAACC,IAAI,CAACJ,MAAM,SAACK;QACb,IAAI,CAACA,KAAK,OAAOH,YAAY,iBAAiB;QAE9CI,IAAAA,kCAAuB,EAACN,MAAM,SAACK;YAC7B,IAAIA,KAAK,OAAOH,SAASG;YACzBE,IAAAA,sBAAO,EAACR,UAAUC,MAAME;QAC1B;IACF;AACF"}
@@ -1,6 +1,6 @@
1
1
  import crypto from 'crypto';
2
2
  import fs from 'fs';
3
- import get from 'get-remote';
3
+ import { getContent } from 'get-file-compat';
4
4
  import { getDist } from 'node-filename-to-dist-paths';
5
5
  import oo from 'on-one';
6
6
  import path from 'path';
@@ -29,24 +29,28 @@ export default function installLib(version, dest, options, callback) {
29
29
  const dist = getDist(version);
30
30
  const npmMajorPair = dist && dist.npm ? +dist.npm.split('.')[0] : NPM_MIN_VERSION;
31
31
  const npmMajor = Math.max(npmMajorPair, NPM_MIN_VERSION);
32
- get(NPM_DIST_TAGS_URL).json((err, res)=>{
32
+ getContent(NPM_DIST_TAGS_URL, 'utf8', (err, res)=>{
33
33
  if (err) return callback(err);
34
- const distTags = res.body;
35
- const npmVersion = distTags[`latest-${npmMajor}`] || distTags[`next-${npmMajor}`] || distTags.latest;
36
- const downloadPath = `${NPM_DIST_URL}/-/npm-${npmVersion}.tgz`;
37
- const cachePath = path.join(options.cachePath, path.basename(downloadPath));
38
- let checksum;
39
- const queue = new Queue(1);
40
- queue.defer(conditionalCache.bind(null, downloadPath, cachePath));
41
- queue.defer((cb)=>{
42
- calculateChecksum(cachePath, (err, hash)=>{
43
- checksum = hash;
44
- cb(err);
34
+ try {
35
+ const distTags = JSON.parse(res.content);
36
+ const npmVersion = distTags[`latest-${npmMajor}`] || distTags[`next-${npmMajor}`] || distTags.latest;
37
+ const downloadPath = `${NPM_DIST_URL}/-/npm-${npmVersion}.tgz`;
38
+ const cachePath = path.join(options.cachePath, path.basename(downloadPath));
39
+ let checksum;
40
+ const queue = new Queue(1);
41
+ queue.defer(conditionalCache.bind(null, downloadPath, cachePath));
42
+ queue.defer((cb)=>{
43
+ calculateChecksum(cachePath, (err, hash)=>{
44
+ checksum = hash;
45
+ cb(err);
46
+ });
45
47
  });
46
- });
47
- queue.defer(extract.bind(null, cachePath, installPath));
48
- queue.await((err)=>{
49
- err ? callback(err) : callback(null, npmVersion, checksum);
50
- });
48
+ queue.defer(extract.bind(null, cachePath, installPath));
49
+ queue.await((err)=>{
50
+ err ? callback(err) : callback(null, npmVersion, checksum);
51
+ });
52
+ } catch (_e) {
53
+ return callback(new Error('Failed to parse npm dist-tags'));
54
+ }
51
55
  });
52
56
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/installNPM/installLib.ts"],"sourcesContent":["import crypto from 'crypto';\nimport fs from 'fs';\nimport get from 'get-remote';\nimport { getDist } from 'node-filename-to-dist-paths';\nimport oo from 'on-one';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport { NPM_DIST_TAGS_URL, NPM_DIST_URL, NPM_MIN_VERSION } from '../constants.ts';\nimport conditionalCache from '../lib/conditionalCache.ts';\nimport extract from '../lib/extract.ts';\n\ninterface DistRecord {\n latest: string;\n}\n\nimport type { InstallOptions } from '../types.ts';\n\nexport type Callback = (error?: Error, npmVersion?: string, checksum?: string) => undefined;\n\nfunction calculateChecksum(filePath: string, callback: (err?: Error, checksum?: string) => void): void {\n const hash = crypto.createHash('sha256');\n const stream = fs.createReadStream(filePath);\n stream.on('data', (data) => hash.update(data));\n oo(stream, ['error', 'end', 'close', 'finish'], (err?: Error) => {\n if (err) return callback(err);\n callback(null, hash.digest('hex'));\n });\n}\n\nexport default function installLib(version: string, dest: string, options: InstallOptions, callback: Callback): undefined {\n const platform = options.platform;\n const libPath = platform === 'win32' ? dest : path.join(dest, 'lib');\n const installPath = path.join(libPath, 'node_modules', 'npm');\n\n const dist = getDist(version);\n const npmMajorPair = dist && dist.npm ? +dist.npm.split('.')[0] : NPM_MIN_VERSION;\n const npmMajor = Math.max(npmMajorPair, NPM_MIN_VERSION);\n\n get(NPM_DIST_TAGS_URL).json((err, res) => {\n if (err) return callback(err);\n const distTags = res.body as DistRecord;\n const npmVersion = distTags[`latest-${npmMajor}`] || distTags[`next-${npmMajor}`] || distTags.latest;\n const downloadPath = `${NPM_DIST_URL}/-/npm-${npmVersion}.tgz`;\n const cachePath = path.join(options.cachePath, path.basename(downloadPath));\n\n let checksum: string | undefined;\n const queue = new Queue(1);\n queue.defer(conditionalCache.bind(null, downloadPath, cachePath));\n queue.defer((cb) => {\n calculateChecksum(cachePath, (err, hash) => {\n checksum = hash;\n cb(err);\n });\n });\n queue.defer(extract.bind(null, cachePath, installPath));\n queue.await((err) => {\n err ? callback(err) : callback(null, npmVersion, checksum);\n });\n });\n}\n"],"names":["crypto","fs","get","getDist","oo","path","Queue","NPM_DIST_TAGS_URL","NPM_DIST_URL","NPM_MIN_VERSION","conditionalCache","extract","calculateChecksum","filePath","callback","hash","createHash","stream","createReadStream","on","data","update","err","digest","installLib","version","dest","options","platform","libPath","join","installPath","dist","npmMajorPair","npm","split","npmMajor","Math","max","json","res","distTags","body","npmVersion","latest","downloadPath","cachePath","basename","checksum","queue","defer","bind","cb","await"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,OAAOC,QAAQ,KAAK;AACpB,OAAOC,SAAS,aAAa;AAC7B,SAASC,OAAO,QAAQ,8BAA8B;AACtD,OAAOC,QAAQ,SAAS;AACxB,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,SAASC,iBAAiB,EAAEC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AACnF,OAAOC,sBAAsB,6BAA6B;AAC1D,OAAOC,aAAa,oBAAoB;AAUxC,SAASC,kBAAkBC,QAAgB,EAAEC,QAAkD;IAC7F,MAAMC,OAAOf,OAAOgB,UAAU,CAAC;IAC/B,MAAMC,SAAShB,GAAGiB,gBAAgB,CAACL;IACnCI,OAAOE,EAAE,CAAC,QAAQ,CAACC,OAASL,KAAKM,MAAM,CAACD;IACxChB,GAAGa,QAAQ;QAAC;QAAS;QAAO;QAAS;KAAS,EAAE,CAACK;QAC/C,IAAIA,KAAK,OAAOR,SAASQ;QACzBR,SAAS,MAAMC,KAAKQ,MAAM,CAA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K;QACnD;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/installNPM/installLib.ts"],"sourcesContent":["import crypto from 'crypto';\nimport fs from 'fs';\nimport { getContent } from 'get-file-compat';\nimport { getDist } from 'node-filename-to-dist-paths';\nimport oo from 'on-one';\nimport path from 'path';\nimport Queue from 'queue-cb';\nimport { NPM_DIST_TAGS_URL, NPM_DIST_URL, NPM_MIN_VERSION } from '../constants.ts';\nimport conditionalCache from '../lib/conditionalCache.ts';\nimport extract from '../lib/extract.ts';\n\ninterface DistRecord {\n latest: string;\n}\n\nimport type { InstallOptions } from '../types.ts';\n\nexport type Callback = (error?: Error, npmVersion?: string, checksum?: string) => undefined;\n\nfunction calculateChecksum(filePath: string, callback: (err?: Error, checksum?: string) => void): void {\n const hash = crypto.createHash('sha256');\n const stream = fs.createReadStream(filePath);\n stream.on('data', (data) => hash.update(data));\n oo(stream, ['error', 'end', 'close', 'finish'], (err?: Error) => {\n if (err) return callback(err);\n callback(null, hash.digest('hex'));\n });\n}\n\nexport default function installLib(version: string, dest: string, options: InstallOptions, callback: Callback): undefined {\n const platform = options.platform;\n const libPath = platform === 'win32' ? dest : path.join(dest, 'lib');\n const installPath = path.join(libPath, 'node_modules', 'npm');\n\n const dist = getDist(version);\n const npmMajorPair = dist && dist.npm ? +dist.npm.split('.')[0] : NPM_MIN_VERSION;\n const npmMajor = Math.max(npmMajorPair, NPM_MIN_VERSION);\n\n getContent(NPM_DIST_TAGS_URL, 'utf8', (err, res) => {\n if (err) return callback(err);\n try {\n const distTags = JSON.parse(res.content) as DistRecord;\n const npmVersion = distTags[`latest-${npmMajor}`] || distTags[`next-${npmMajor}`] || distTags.latest;\n const downloadPath = `${NPM_DIST_URL}/-/npm-${npmVersion}.tgz`;\n const cachePath = path.join(options.cachePath, path.basename(downloadPath));\n\n let checksum: string | undefined;\n const queue = new Queue(1);\n queue.defer(conditionalCache.bind(null, downloadPath, cachePath));\n queue.defer((cb) => {\n calculateChecksum(cachePath, (err, hash) => {\n checksum = hash;\n cb(err);\n });\n });\n queue.defer(extract.bind(null, cachePath, installPath));\n queue.await((err) => {\n err ? callback(err) : callback(null, npmVersion, checksum);\n });\n } catch (_e) {\n return callback(new Error('Failed to parse npm dist-tags'));\n }\n });\n}\n"],"names":["crypto","fs","getContent","getDist","oo","path","Queue","NPM_DIST_TAGS_URL","NPM_DIST_URL","NPM_MIN_VERSION","conditionalCache","extract","calculateChecksum","filePath","callback","hash","createHash","stream","createReadStream","on","data","update","err","digest","installLib","version","dest","options","platform","libPath","join","installPath","dist","npmMajorPair","npm","split","npmMajor","Math","max","res","distTags","JSON","parse","content","npmVersion","latest","downloadPath","cachePath","basename","checksum","queue","defer","bind","cb","await","_e","Error"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,OAAOC,QAAQ,KAAK;AACpB,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,OAAO,QAAQ,8BAA8B;AACtD,OAAOC,QAAQ,SAAS;AACxB,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAAW,WAAW;AAC7B,SAASC,iBAAiB,EAAEC,YAAY,EAAEC,eAAe,QAAQ,kBAAkB;AACnF,OAAOC,sBAAsB,6BAA6B;AAC1D,OAAOC,aAAa,oBAAoB;AAUxC,SAASC,kBAAkBC,QAAgB,EAAEC,QAAkD;IAC7F,MAAMC,OAAOf,OAAOgB,UAAU,CAAC;IAC/B,MAAMC,SAAShB,GAAGiB,gBAAgB,CAACL;IACnCI,OAAOE,EAAE,CAAC,QAAQ,CAACC,OAASL,KAAKM,MAAM,CAACD;IACxChB,GAAGa,QAAQ;QAAC;QAAS;QAAO;QAAS;KAAS,EAAE,CAACK;QAC/C,IAAIA,KAAK,OAAOR,SAASQ;QACzBR,SAAS,MAAMC,KAAKQ,MAAM,CAAC;IAC7B;AACF;AAEA,eAAe,SAASC,WAAWC,OAAe,EAAEC,IAAY,EAAEC,OAAuB,EAAEb,QAAkB;IAC3G,MAA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B;IACF;AACF"}
@@ -1,14 +1,14 @@
1
1
  import crypto from 'crypto';
2
2
  import fs from 'fs';
3
- import get from 'get-remote';
3
+ import { getContent } from 'get-file-compat';
4
4
  import oo from 'on-one';
5
5
  import { NODE_DIST_BASE_URL } from '../constants.js';
6
6
  export default function validateDownload(distPath, installPath, callback) {
7
7
  const version = distPath.split('/')[0];
8
8
  const downloadPath = `${NODE_DIST_BASE_URL}/${version}/SHASUMS256.txt`;
9
- get(downloadPath).text((err, res)=>{
9
+ getContent(downloadPath, 'utf8', (err, res)=>{
10
10
  if (err) return callback(err);
11
- const text = res.body;
11
+ const text = res.content;
12
12
  const filename = distPath.split('/').slice(1).join('/');
13
13
  const expected = text.split(filename)[0].split('\n').pop().trim();
14
14
  const hash = crypto.createHash('sha256');
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/installNode/validateDownload.ts"],"sourcesContent":["import crypto from 'crypto';\nimport fs from 'fs';\nimport get from 'get-remote';\nimport oo from 'on-one';\nimport { NODE_DIST_BASE_URL } from '../constants.ts';\n\nimport type { ChecksumCallback, ChecksumResult } from '../types.ts';\n\nexport default function validateDownload(distPath: string, installPath: string, callback: ChecksumCallback): undefined {\n const version = distPath.split('/')[0];\n const downloadPath = `${NODE_DIST_BASE_URL}/${version}/SHASUMS256.txt`;\n get(downloadPath).text((err, res) => {\n if (err) return callback(err);\n const text = res.body;\n const filename = distPath.split('/').slice(1).join('/');\n const expected = text.split(filename)[0].split('\\n').pop().trim();\n const hash = crypto.createHash('sha256');\n const stream = fs.createReadStream(installPath);\n stream.on('data', (data) => hash.update(data));\n oo(stream, ['error', 'end', 'close', 'finish'], (err?: Error) => {\n if (err) {\n callback(err);\n return;\n }\n const actual = hash.digest('hex');\n const match = actual === expected;\n const checksum: ChecksumResult = { actual, expected, match };\n match ? callback(null, checksum) : callback(new Error(`${filename} checksum failed`), checksum);\n });\n });\n}\n"],"names":["crypto","fs","get","oo","NODE_DIST_BASE_URL","validateDownload","distPath","installPath","callback","version","split","downloadPath","text","err","res","body","filename","slice","join","expected","pop","trim","hash","createHash","stream","createReadStream","on","data","update","actual","digest","match","checksum","Error"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,OAAOC,QAAQ,KAAK;AACpB,OAAOC,SAAS,aAAa;AAC7B,OAAOC,QAAQ,SAAS;AACxB,SAASC,kBAAkB,QAAQ,kBAAkB;AAIrD,eAAe,SAASC,iBAAiBC,QAAgB,EAAEC,WAAmB,EAAEC,QAA0B;IACxG,MAAMC,UAAUH,SAASI,KAAK,CAAC,IAAI,CAAC,EAAE;IACtC,MAAMC,eAAe,GAAGP,mBAAmB,CAAC,EAAEK,QAAQ,eAAe,CAAC;IACtEP,IAAIS,cAAcC,IAAI,CAAC,CAACC,KAAKC;QAC3B,IAAID,KAAK,OAAOL,SAASK;QACzB,MAAMD,OAAOE,IAAIC,IAAI;QACrB,MAAMC,WAAWV,SAASI,KAAK,CAAC,KAAKO,KAAK,CAAC,GAAGC,IAAI,CAAC;QACnD,MAAMC,WAAWP,KAAKF,KAAK,CAACM,SAAS,CAAC,EAAE,CAACN,KAAK,CAAC,MAAMU,GAAG,GAAGC,IAAI;QAC/D,MAAMC,OAAOtB,OAAOuB,UAAU,CAAC;QAC/B,MAAMC,SAASvB,GAAGwB,gBAAgB,CAAClB;QACnCiB,OAAOE,EAAE,CAAC,QAAQ,CAACC,OAASL,KAAKM,MAAM,CAACD;QACxCxB,GAAGqB,QAAQ;YAAC;YAAS;YAAO;YAAS;SAAS,EAAE,CAACX;YAC/C,IAAIA,KAAK;gBACPL,SAASK;gBACT;YACF;YACA,MAAMgB,SAASP,KAAKQ,MAAM,CAAC;YAC3B,MAAMC,QAAQF,WAAWV;YACzB,MAAMa,WAA2B;gBAAEH;gBAAQV;gBAAUY;YAAM;YAC3DA,QAAQvB,SAAS,MAAMwB,YAAYxB,SAAS,IAAIyB,MAAM,GAAGjB,SAAS,gBAAgB,CAAC,GAAGgB;QACxF;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/installNode/validateDownload.ts"],"sourcesContent":["import crypto from 'crypto';\nimport fs from 'fs';\nimport { getContent } from 'get-file-compat';\nimport oo from 'on-one';\nimport { NODE_DIST_BASE_URL } from '../constants.ts';\n\nimport type { ChecksumCallback, ChecksumResult } from '../types.ts';\n\nexport default function validateDownload(distPath: string, installPath: string, callback: ChecksumCallback): undefined {\n const version = distPath.split('/')[0];\n const downloadPath = `${NODE_DIST_BASE_URL}/${version}/SHASUMS256.txt`;\n getContent(downloadPath, 'utf8', (err, res) => {\n if (err) return callback(err);\n const text = res.content;\n const filename = distPath.split('/').slice(1).join('/');\n const expected = text.split(filename)[0].split('\\n').pop().trim();\n const hash = crypto.createHash('sha256');\n const stream = fs.createReadStream(installPath);\n stream.on('data', (data) => hash.update(data));\n oo(stream, ['error', 'end', 'close', 'finish'], (err?: Error) => {\n if (err) {\n callback(err);\n return;\n }\n const actual = hash.digest('hex');\n const match = actual === expected;\n const checksum: ChecksumResult = { actual, expected, match };\n match ? callback(null, checksum) : callback(new Error(`${filename} checksum failed`), checksum);\n });\n });\n}\n"],"names":["crypto","fs","getContent","oo","NODE_DIST_BASE_URL","validateDownload","distPath","installPath","callback","version","split","downloadPath","err","res","text","content","filename","slice","join","expected","pop","trim","hash","createHash","stream","createReadStream","on","data","update","actual","digest","match","checksum","Error"],"mappings":"AAAA,OAAOA,YAAY,SAAS;AAC5B,OAAOC,QAAQ,KAAK;AACpB,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,OAAOC,QAAQ,SAAS;AACxB,SAASC,kBAAkB,QAAQ,kBAAkB;AAIrD,eAAe,SAASC,iBAAiBC,QAAgB,EAAEC,WAAmB,EAAEC,QAA0B;IACxG,MAAMC,UAAUH,SAASI,KAAK,CAAC,IAAI,CAAC,EAAE;IACtC,MAAMC,eAAe,GAAGP,mBAAmB,CAAC,EAAEK,QAAQ,eAAe,CAAC;IACtEP,WAAWS,cAAc,QAAQ,CAACC,KAAKC;QACrC,IAAID,KAAK,OAAOJ,SAASI;QACzB,MAAME,OAAOD,IAAIE,OAAO;QACxB,MAAMC,WAAWV,SAASI,KAAK,CAAC,KAAKO,KAAK,CAAC,GAAGC,IAAI,CAAC;QACnD,MAAMC,WAAWL,KAAKJ,KAAK,CAACM,SAAS,CAAC,EAAE,CAACN,KAAK,CAAC,MAAMU,GAAG,GAAGC,IAAI;QAC/D,MAAMC,OAAOtB,OAAOuB,UAAU,CAAC;QAC/B,MAAMC,SAASvB,GAAGwB,gBAAgB,CAAClB;QACnCiB,OAAOE,EAAE,CAAC,QAAQ,CAACC,OAASL,KAAKM,MAAM,CAACD;QACxCxB,GAAGqB,QAAQ;YAAC;YAAS;YAAO;YAAS;SAAS,EAAE,CAACZ;YAC/C,IAAIA,KAAK;gBACPJ,SAASI;gBACT;YACF;YACA,MAAMiB,SAASP,KAAKQ,MAAM,CAAC;YAC3B,MAAMC,QAAQF,WAAWV;YACzB,MAAMa,WAA2B;gBAAEH;gBAAQV;gBAAUY;YAAM;YAC3DA,QAAQvB,SAAS,MAAMwB,YAAYxB,SAAS,IAAIyB,MAAM,GAAGjB,SAAS,gBAAgB,CAAC,GAAGgB;QACxF;IACF;AACF"}
@@ -1,6 +1,5 @@
1
1
  import fs from 'fs';
2
- import get from 'get-remote';
3
- import path from 'path';
2
+ import { getFile } from 'get-file-compat';
4
3
  import ensureDestinationParent from './ensureDestinationParent.js';
5
4
  export default function conditionalCache(endpoint, dest, options, callback) {
6
5
  if (typeof options === 'function') {
@@ -12,10 +11,7 @@ export default function conditionalCache(endpoint, dest, options, callback) {
12
11
  if (!err) return callback(); // already exists
13
12
  ensureDestinationParent(dest, (err)=>{
14
13
  if (err) return callback(err);
15
- get(endpoint, {
16
- filename: path.basename(dest),
17
- time: 1000
18
- }).file(path.dirname(dest), callback);
14
+ getFile(endpoint, dest, callback);
19
15
  });
20
16
  });
21
17
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/lib/conditionalCache.ts"],"sourcesContent":["import fs from 'fs';\nimport get from 'get-remote';\nimport path from 'path';\nimport type { InstallOptions, NoParamCallback } from '../types.ts';\nimport ensureDestinationParent from './ensureDestinationParent.ts';\n\nexport default function conditionalCache(endpoint: string, dest: string, options: InstallOptions, callback?: NoParamCallback): undefined {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n options = options || {};\n\n fs.stat(dest, (err) => {\n if (!err) return callback(); // already exists\n\n ensureDestinationParent(dest, (err) => {\n if (err) return callback(err);\n get(endpoint, { filename: path.basename(dest), time: 1000 }).file(path.dirname(dest), callback);\n });\n });\n}\n"],"names":["fs","get","path","ensureDestinationParent","conditionalCache","endpoint","dest","options","callback","stat","err","filename","basename","time","file","dirname"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,OAAOC,SAAS,aAAa;AAC7B,OAAOC,UAAU,OAAO;AAExB,OAAOC,6BAA6B,+BAA+B;AAEnE,eAAe,SAASC,iBAAiBC,QAAgB,EAAEC,IAAY,EAAEC,OAAuB,EAAEC,QAA0B;IAC1H,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU;IACZ;IACAA,UAAUA,WAAW,CAAC;IAEtBP,GAAGS,IAAI,CAACH,MAAM,CAACI;QACb,IAAI,CAACA,KAAK,OAAOF,YAAY,iBAAiB;QAE9CL,wBAAwBG,MAAM,CAACI;YAC7B,IAAIA,KAAK,OAAOF,SAASE;YACzBT,IAAII,UAAU;gBAAEM,UAAUT,KAAKU,QAAQ,CAACN;gBAAOO,MAAM;YAAK,GAAGC,IAAI,CAACZ,KAAKa,OAAO,CAACT,OAAOE;QACxF;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/node-version/node-install-release/src/lib/conditionalCache.ts"],"sourcesContent":["import fs from 'fs';\nimport { getFile } from 'get-file-compat';\nimport type { InstallOptions, NoParamCallback } from '../types.ts';\nimport ensureDestinationParent from './ensureDestinationParent.ts';\n\nexport default function conditionalCache(endpoint: string, dest: string, options: InstallOptions, callback?: NoParamCallback): undefined {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n options = options || {};\n\n fs.stat(dest, (err) => {\n if (!err) return callback(); // already exists\n\n ensureDestinationParent(dest, (err) => {\n if (err) return callback(err);\n getFile(endpoint, dest, callback);\n });\n });\n}\n"],"names":["fs","getFile","ensureDestinationParent","conditionalCache","endpoint","dest","options","callback","stat","err"],"mappings":"AAAA,OAAOA,QAAQ,KAAK;AACpB,SAASC,OAAO,QAAQ,kBAAkB;AAE1C,OAAOC,6BAA6B,+BAA+B;AAEnE,eAAe,SAASC,iBAAiBC,QAAgB,EAAEC,IAAY,EAAEC,OAAuB,EAAEC,QAA0B;IAC1H,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU;IACZ;IACAA,UAAUA,WAAW,CAAC;IAEtBN,GAAGQ,IAAI,CAACH,MAAM,CAACI;QACb,IAAI,CAACA,KAAK,OAAOF,YAAY,iBAAiB;QAE9CL,wBAAwBG,MAAM,CAACI;YAC7B,IAAIA,KAAK,OAAOF,SAASE;YACzBR,QAAQG,UAAUC,MAAME;QAC1B;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-install-release",
3
- "version": "1.16.5",
3
+ "version": "1.17.0",
4
4
  "description": "Cross-platform solution for installing releases of Node.js",
5
5
  "keywords": [
6
6
  "node",
@@ -43,36 +43,35 @@
43
43
  "version": "tsds version"
44
44
  },
45
45
  "dependencies": {
46
- "cpu-arch": "^1.0.8",
47
- "cross-spawn-cb": "^2.4.14",
48
- "exit-compat": "^1.0.4",
49
- "fast-extract": "^1.8.16",
50
- "fs-copy-compat": "^0.1.5",
51
- "fs-remove-compat": "^0.2.4",
52
- "get-remote": "^2.3.4",
46
+ "cpu-arch": "^1.0.1",
47
+ "cross-spawn-cb": "^2.0.0",
48
+ "exit-compat": "^1.0.0",
49
+ "fast-extract": "^1.0.1",
50
+ "fs-copy-compat": "^1.0.0",
51
+ "fs-remove-compat": "^1.0.0",
52
+ "get-file-compat": "^2.0.0",
53
53
  "getopts-compat": "^2.2.6",
54
54
  "homedir-polyfill": "^1.0.3",
55
55
  "is-version": "^1.0.9",
56
56
  "lodash.keys": "^4.2.0",
57
- "mkdirp-classic": "^0.5.3",
57
+ "mkdirp-classic": "^0.5.2",
58
58
  "node-filename-to-dist-paths": "^1.3.15",
59
59
  "node-resolve-versions": "^1.3.13",
60
60
  "on-one": "^1.0.10",
61
- "queue-cb": "^1.6.3",
61
+ "queue-cb": "^1.0.0",
62
62
  "temp-suffix": "^1.0.10"
63
63
  },
64
64
  "devDependencies": {
65
- "@types/mocha": "^10.0.10",
66
- "@types/node": "^25.0.2",
65
+ "@types/mocha": "*",
66
+ "@types/node": "*",
67
67
  "cr": "^0.1.0",
68
- "lodash.find": "^4.6.0",
69
68
  "lodash.values": "^4.3.0",
70
69
  "node-version-compare": "^1.0.3",
71
- "node-version-use": "^2.1.7",
72
- "node-version-utils": "^1.3.17",
73
- "pinkie-promise": "^2.0.1",
74
- "ts-dev-stack": "^1.21.3",
75
- "tsds-config": "^0.2.2"
70
+ "node-version-use": "*",
71
+ "node-version-utils": "^1.0.2",
72
+ "pinkie-promise": "*",
73
+ "ts-dev-stack": "*",
74
+ "tsds-config": "*"
76
75
  },
77
76
  "engines": {
78
77
  "node": ">=0.8"