node-install-release 0.4.0 → 0.4.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.
@@ -1,29 +1,38 @@
1
1
  var path = require('path');
2
- var match = require('match-semver');
3
- var find = require('lodash.find');
4
2
  var get = require('get-remote');
5
3
 
6
4
  var conditionalCache = require('../conditionalCache');
7
5
  var conditionalExtract = require('../conditionalExtract');
8
- var npmVersions = require('./npmVersions');
9
6
 
10
- var DIST_URL = 'https://registry.npmjs.org/npm';
7
+ var NODE_DIST_URL = 'https://nodejs.org/dist/index.json';
8
+ var NPM_DIST_URL = 'https://registry.npmjs.org/npm';
9
+ var NPM_MIN_VERSION = '1.0.0';
11
10
 
12
11
  module.exports = function installLib(version, dest, options, callback) {
13
12
  var platform = options.platform || process.platform;
14
- var maximumVersion = find(npmVersions, match.bind(null, version.version)).maximum;
15
13
  var libPath = platform === 'win32' ? dest : path.join(dest, 'lib');
16
14
  var installPath = path.join(libPath, 'node_modules', 'npm');
17
15
 
18
- get(DIST_URL).json(function (err, res) {
16
+ get(NODE_DIST_URL).json(function (err, res1) {
19
17
  if (err) return callback(err);
18
+ var releases = res1.body;
20
19
 
21
- var installVersion = res.body['dist-tags'][maximumVersion ? 'latest-' + maximumVersion : 'latest'];
22
- var downloadPath = DIST_URL + '/-/npm-' + installVersion + '.tgz';
23
- var cachePath = path.join(options.cacheDirectory, path.basename(downloadPath));
24
- conditionalCache(downloadPath, cachePath, function (err) {
20
+ var found = releases.find(function (record) {
21
+ return record.version === version.version;
22
+ });
23
+ var npm = (found ? found.npm : null) || NPM_MIN_VERSION;
24
+ var maximumVersion = +npm.split('.')[0];
25
+
26
+ get(NPM_DIST_URL).json(function (err, res2) {
25
27
  if (err) return callback(err);
26
- conditionalExtract(cachePath, installPath, callback);
28
+
29
+ var installVersion = res2.body['dist-tags'][maximumVersion ? 'latest-' + maximumVersion : 'latest'];
30
+ var downloadPath = NPM_DIST_URL + '/-/npm-' + installVersion + '.tgz';
31
+ var cachePath = path.join(options.cacheDirectory, path.basename(downloadPath));
32
+ conditionalCache(downloadPath, cachePath, function (err) {
33
+ if (err) return callback(err);
34
+ conditionalExtract(cachePath, installPath, callback);
35
+ });
27
36
  });
28
37
  });
29
38
  };
@@ -1,4 +1,6 @@
1
1
  var path = require('path');
2
+ var access = require('fs-access-compat');
3
+ var rimraf = require('rimraf');
2
4
 
3
5
  var conditionalCache = require('../conditionalCache');
4
6
  var conditionalExtract = require('../conditionalExtract');
@@ -10,9 +12,20 @@ module.exports = function installCompressed(relativePath, dest, record, options,
10
12
 
11
13
  conditionalCache(downloadPath, cachePath, function (err) {
12
14
  if (err) return callback(err);
13
- conditionalExtract(cachePath, dest, Object.assign({ strip: 1, progress: progress, time: 1000 }, options), function (err) {
14
- console.log('');
15
- callback(err);
15
+ access(dest, function (err) {
16
+ if (!err) return callback(); // already exists
17
+ conditionalExtract(cachePath, dest, Object.assign({ strip: 1, progress: progress, time: 1000 }, options), function (err) {
18
+ console.log('');
19
+ if (err) return callback(err);
20
+
21
+ // some compressed versions of node come with npm pre-installed, but we want to override with a specific version
22
+ var platform = options.platform || process.platform;
23
+ var libPath = platform === 'win32' ? dest : path.join(dest, 'lib');
24
+ var installPath = path.join(libPath, 'node_modules', 'npm');
25
+ rimraf(installPath, function () {
26
+ callback(err);
27
+ });
28
+ });
16
29
  });
17
30
  });
18
31
  };
@@ -1,8 +1,8 @@
1
1
  var path = require('path');
2
+ var access = require('fs-access-compat');
2
3
 
3
4
  var conditionalCache = require('../conditionalCache');
4
5
  var copyFile = require('../copyFile');
5
- var access = require('fs-access-compat');
6
6
 
7
7
  module.exports = function installExe(relativePath, dest, record, options, callback) {
8
8
  var downloadPath = options.downloadURL(relativePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-install-release",
3
- "version": "0.4.0",
3
+ "version": "0.4.3",
4
4
  "description": "Cross-platform solution for installing releases of Node.js",
5
5
  "keywords": [
6
6
  "node",
@@ -36,18 +36,17 @@
36
36
  "cross-spawn-cb": "^0.6.14",
37
37
  "end-with": "^1.0.2",
38
38
  "exit": "^0.1.2",
39
- "fast-extract": "^0.4.1",
39
+ "fast-extract": "^0.4.3",
40
40
  "fs-access-compat": "^1.0.3",
41
41
  "function-exec-sync": "^0.2.10",
42
- "get-remote": "^0.8.0",
42
+ "get-remote": "^0.8.1",
43
43
  "getopts-compat": "^2.2.5",
44
44
  "isarray": "^2.0.5",
45
45
  "lodash.find": "^4.6.0",
46
46
  "lodash.keys": "^4.2.0",
47
- "match-semver": "^0.1.1",
48
47
  "mkpath": "^1.0.0",
49
- "node-filename-to-dist-paths": "^0.2.0",
50
- "node-resolve-versions": "^0.3.8",
48
+ "node-filename-to-dist-paths": "^0.2.1",
49
+ "node-resolve-versions": "^0.3.9",
51
50
  "osenv": "^0.1.5",
52
51
  "pump": "^3.0.0",
53
52
  "queue-cb": "^1.1.7",
@@ -1,8 +0,0 @@
1
- module.exports = [
2
- { gte: '10.0.0', bundled: '6.14.4' },
3
- { gte: '8.0.0', lt: '10.0.0', bundled: '6.13.4' },
4
- { gte: '6.0.0', lt: '8.0.0', bundled: '3.10.10' },
5
- { gte: '4.0.0', lt: '6.0.0', bundled: '2.15.11', maximum: 5 },
6
- { gte: '0.12.0', lt: '4.0.0', bundled: '2.15.11', maximum: 3 },
7
- { lt: '0.12.0', bundled: '1.2.30', maximum: 3 },
8
- ];