node-semvers 0.5.3 → 0.5.6

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/bin/cache.js ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+
3
+ var Cache = require('fetch-json-cache');
4
+ var exit = require('exit');
5
+ var constants = require('../lib/constants');
6
+
7
+ var cache = new Cache(constants.CACHE_DIRECTORY);
8
+
9
+ function cacheJSON(callback) {
10
+ cache.get(constants.DISTS_URL, { force: true }, function (err) {
11
+ err ? callback(err) : cache.get(constants.SCHEDULES_URL, { force: true }, callback);
12
+ });
13
+ }
14
+
15
+ cacheJSON(function (err) {
16
+ if (err) {
17
+ console.log('Failed to cache dists and schedules. Error: ' + err.message);
18
+ return exit(err.code || -1);
19
+ }
20
+ exit(0);
21
+ });
package/lib/index.js CHANGED
@@ -52,6 +52,15 @@ NodeVersions.load = function load(options, callback) {
52
52
  }
53
53
  };
54
54
 
55
+ NodeVersions.loadAsync = function loadAsync(options) {
56
+ options = options || {};
57
+ var cache = new Cache(options.cacheDirectory || constants.CACHE_DIRECTORY);
58
+ var versions = cache.getAsync(constants.DISTS_URL);
59
+ var schedule = cache.getAsync(constants.SCHEDULES_URL);
60
+ if (!versions || !schedule) return null;
61
+ return new NodeVersions(versions, schedule);
62
+ };
63
+
55
64
  NodeVersions.prototype.resolve = function resolve(expression, options) {
56
65
  options = options || {};
57
66
  var path = options.path || 'version';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-semvers",
3
- "version": "0.5.3",
3
+ "version": "0.5.6",
4
4
  "description": "Utilities for managing versions of node including looking up codenames",
5
5
  "keywords": [
6
6
  "node",
@@ -22,7 +22,8 @@
22
22
  "nsv": "./bin/node-semvers.js"
23
23
  },
24
24
  "files": [
25
- "lib"
25
+ "lib",
26
+ "bin"
26
27
  ],
27
28
  "scripts": {
28
29
  "format": "prettier --write .",
@@ -33,22 +34,22 @@
33
34
  },
34
35
  "dependencies": {
35
36
  "exit": "^0.1.2",
36
- "fetch-json-cache": "^0.1.10",
37
+ "fetch-json-cache": "^0.1.12",
37
38
  "getopts-compat": "^2.2.5",
38
39
  "isarray": "^2.0.5",
39
40
  "semver": "^5.7.1"
40
41
  },
41
42
  "devDependencies": {
42
- "@typescript-eslint/parser": "^5.30.0",
43
+ "@typescript-eslint/parser": "^5.30.5",
43
44
  "cr": "^0.1.0",
44
- "cross-spawn-cb": "^0.5.9",
45
+ "cross-spawn-cb": "^0.5.12",
45
46
  "depcheck": "^1.4.3",
46
- "dis-dat": "^0.1.6",
47
- "eslint": "^8.18.0",
47
+ "dis-dat": "^0.1.7",
48
+ "eslint": "^8.19.0",
48
49
  "eslint-config-prettier": "^8.5.0",
49
50
  "eslint-config-standard": "^17.0.0",
50
51
  "eslint-plugin-import": "^2.26.0",
51
- "eslint-plugin-n": "^15.2.3",
52
+ "eslint-plugin-n": "^15.2.4",
52
53
  "eslint-plugin-promise": "^6.0.0",
53
54
  "mocha-compat": "^3.5.5",
54
55
  "prettier": "^2.7.1",