node-version-alias
Advanced tools
Comparing version 1.0.1 to 2.0.0
@@ -1,5 +0,5 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getConstantAlias=void 0;var _nvm=require("./nvm.js"); | ||
import{getNvmSystemVersion}from"./nvm.js"; | ||
const getConstantAlias=function(alias){ | ||
export const getConstantAlias=function(alias){ | ||
const versionRange=ALIASES[alias]; | ||
@@ -16,3 +16,3 @@ | ||
return versionRange(); | ||
};exports.getConstantAlias=getConstantAlias; | ||
}; | ||
@@ -29,3 +29,3 @@ const ALIASES={ | ||
system:_nvm.getNvmSystemVersion, | ||
system:getNvmSystemVersion, | ||
@@ -32,0 +32,0 @@ |
@@ -1,6 +0,6 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getLtsMajors=exports.getLtsAlias=void 0;var _allNodeVersions=_interopRequireDefault(require("all-node-versions"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} | ||
import allNodeVersions from"all-node-versions"; | ||
const getLtsAlias=async function(alias,allNodeOpts){ | ||
export const getLtsAlias=async function(alias,allNodeOpts){ | ||
const ltsMajors=await getLtsMajors(allNodeOpts); | ||
@@ -14,9 +14,9 @@ const major=getLtsMajor(alias,ltsMajors); | ||
return major.latest; | ||
};exports.getLtsAlias=getLtsAlias; | ||
}; | ||
const getLtsMajors=async function(allNodeOpts){ | ||
const{majors}=await(0,_allNodeVersions.default)(allNodeOpts); | ||
export const getLtsMajors=async function(allNodeOpts){ | ||
const{majors}=await allNodeVersions(allNodeOpts); | ||
return majors.filter(isLts); | ||
};exports.getLtsMajors=getLtsMajors; | ||
}; | ||
@@ -23,0 +23,0 @@ const isLts=function({lts}){ |
@@ -1,13 +0,13 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.nodeVersionAlias=void 0;var _normalizeNodeVersion=_interopRequireDefault(require("normalize-node-version")); | ||
var _semver=require("semver"); | ||
import normalizeNodeVersion from"normalize-node-version"; | ||
import semver from"semver"; | ||
var _constant=require("./constant.js"); | ||
var _lts=require("./lts.js"); | ||
var _nvm=require("./nvm.js"); | ||
var _options=require("./options.js");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} | ||
import{getConstantAlias}from"./constant.js"; | ||
import{getLtsAlias}from"./lts.js"; | ||
import{getNvmCustomAlias}from"./nvm.js"; | ||
import{getOpts}from"./options.js"; | ||
const nodeVersionAlias=async function(alias,opts){ | ||
const{allNodeOpts,normalizeOpts}=(0,_options.getOpts)(opts); | ||
export default async function nodeVersionAlias(alias,opts){ | ||
const{allNodeOpts,normalizeOpts}=getOpts(opts); | ||
const versionRange=await getVersionRange(alias,allNodeOpts); | ||
@@ -19,12 +19,12 @@ | ||
const version=await(0,_normalizeNodeVersion.default)(versionRange,normalizeOpts); | ||
const version=await normalizeNodeVersion(versionRange,normalizeOpts); | ||
return version; | ||
};exports.nodeVersionAlias=nodeVersionAlias; | ||
} | ||
const getVersionRange=async function(alias,allNodeOpts){ | ||
if((0,_semver.validRange)(alias)!==null){ | ||
if(semver.validRange(alias)!==null){ | ||
return alias; | ||
} | ||
const versionRange=await(0,_constant.getConstantAlias)(alias); | ||
const versionRange=await getConstantAlias(alias); | ||
@@ -35,3 +35,3 @@ if(versionRange!==undefined){ | ||
const versionRangeA=await(0,_lts.getLtsAlias)(alias,allNodeOpts); | ||
const versionRangeA=await getLtsAlias(alias,allNodeOpts); | ||
@@ -47,3 +47,3 @@ if(versionRangeA!==undefined){ | ||
const getRecursiveNvmAlias=async function(alias,allNodeOpts){ | ||
const aliasResult=await(0,_nvm.getNvmCustomAlias)(alias); | ||
const aliasResult=await getNvmCustomAlias(alias); | ||
@@ -56,6 +56,2 @@ if(aliasResult===undefined){ | ||
}; | ||
module.exports=nodeVersionAlias; | ||
//# sourceMappingURL=main.js.map |
@@ -1,29 +0,29 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getNvmSystemVersion=exports.getNvmCustomAlias=void 0;var _child_process=require("child_process"); | ||
var _path=require("path"); | ||
var _process=require("process"); | ||
var _util=require("util"); | ||
import{execFile}from"child_process"; | ||
import{join}from"path"; | ||
import{env}from"process"; | ||
import{promisify}from"util"; | ||
var _pathExists=_interopRequireDefault(require("path-exists"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} | ||
import pathExists from"path-exists"; | ||
const pExecFile=(0,_util.promisify)(_child_process.execFile); | ||
const pExecFile=promisify(execFile); | ||
const getNvmCustomAlias=function(alias){ | ||
export const getNvmCustomAlias=function(alias){ | ||
return runNvmCommand(`nvm_alias ${alias}`); | ||
};exports.getNvmCustomAlias=getNvmCustomAlias; | ||
}; | ||
const getNvmSystemVersion=function(){ | ||
export const getNvmSystemVersion=function(){ | ||
return runNvmCommand("nvm deactivate >/dev/null && node --version"); | ||
};exports.getNvmSystemVersion=getNvmSystemVersion; | ||
}; | ||
const runNvmCommand=async function(command){ | ||
if(!_process.env.NVM_DIR){ | ||
if(!env.NVM_DIR){ | ||
return; | ||
} | ||
const nvmPath=(0,_path.join)(_process.env.NVM_DIR,"nvm.sh"); | ||
const nvmPath=join(env.NVM_DIR,"nvm.sh"); | ||
if(!(await(0,_pathExists.default)(nvmPath))){ | ||
if(!(await pathExists(nvmPath))){ | ||
return; | ||
@@ -30,0 +30,0 @@ } |
@@ -1,9 +0,9 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getOpts=void 0;var _filterObj=_interopRequireDefault(require("filter-obj")); | ||
var _jestValidate=require("jest-validate");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}} | ||
import filterObj from"filter-obj"; | ||
import{validate}from"jest-validate"; | ||
const getOpts=function(opts={}){ | ||
(0,_jestValidate.validate)(opts,{exampleConfig:EXAMPLE_OPTS}); | ||
export const getOpts=function(opts={}){ | ||
validate(opts,{exampleConfig:EXAMPLE_OPTS}); | ||
const optsA=(0,_filterObj.default)(opts,isDefined); | ||
const optsA=filterObj(opts,isDefined); | ||
const optsB={...DEFAULT_OPTS,...optsA}; | ||
@@ -15,3 +15,3 @@ | ||
return{normalizeOpts,allNodeOpts}; | ||
};exports.getOpts=getOpts; | ||
}; | ||
@@ -18,0 +18,0 @@ const DEFAULT_OPTS={}; |
{ | ||
"name": "node-version-alias", | ||
"version": "1.0.1", | ||
"main": "build/src/main.js", | ||
"version": "2.0.0", | ||
"type": "module", | ||
"exports": "./build/src/main.js", | ||
"main": "./build/src/main.js", | ||
"files": [ | ||
"build/src", | ||
"!*~" | ||
"build/src/**/*.{js,ts,map,json,sh,md}", | ||
"examples/**/*.{js,ts,map,json,sh,md}" | ||
], | ||
@@ -12,7 +14,2 @@ "scripts": { | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-push": "gulp -LL check --full" | ||
} | ||
}, | ||
"description": "Resolve Node.js version aliases like 'latest', 'lts' or 'erbium'", | ||
@@ -53,20 +50,17 @@ "keywords": [ | ||
"dependencies": { | ||
"all-node-versions": "^8.0.0", | ||
"all-node-versions": "^9.0.0", | ||
"filter-obj": "^2.0.1", | ||
"jest-validate": "^25.3.0", | ||
"normalize-node-version": "^10.0.0", | ||
"jest-validate": "^27.0.2", | ||
"normalize-node-version": "^11.0.0", | ||
"path-exists": "^4.0.0", | ||
"semver": "^7.3.2" | ||
"semver": "^7.3.5" | ||
}, | ||
"devDependencies": { | ||
"@ehmicky/dev-tasks": "^0.31.36", | ||
"ava": "^3.7.1", | ||
"got": "^10.7.0", | ||
"gulp": "^4.0.2", | ||
"husky": "^4.2.5", | ||
"test-each": "^2.0.0" | ||
"@ehmicky/dev-tasks": "^1.0.34", | ||
"got": "^11.8.2", | ||
"test-each": "^3.0.1" | ||
}, | ||
"engines": { | ||
"node": ">=10.17.0" | ||
"node": ">=12.20.0" | ||
} | ||
} |
[![Codecov](https://img.shields.io/codecov/c/github/ehmicky/node-version-alias.svg?label=tested&logo=codecov)](https://codecov.io/gh/ehmicky/node-version-alias) | ||
[![Build](https://github.com/ehmicky/node-version-alias/workflows/Build/badge.svg)](https://github.com/ehmicky/node-version-alias/actions) | ||
[![Node](https://img.shields.io/node/v/node-version-alias.svg?logo=node.js)](https://www.npmjs.com/package/node-version-alias) | ||
[![Gitter](https://img.shields.io/gitter/room/ehmicky/node-version-alias.svg?logo=gitter)](https://gitter.im/ehmicky/node-version-alias) | ||
[![Twitter](https://img.shields.io/badge/%E2%80%8B-twitter-4cc61e.svg?logo=twitter)](https://twitter.com/intent/follow?screen_name=ehmicky) | ||
@@ -46,3 +45,3 @@ [![Medium](https://img.shields.io/badge/%E2%80%8B-medium-4cc61e.svg?logo=medium)](https://medium.com/@ehmicky) | ||
```js | ||
const nodeVersionAlias = require('node-version-alias') | ||
import nodeVersionAlias from 'node-version-alias' | ||
@@ -77,2 +76,6 @@ // Note: the following examples might be out-of-sync with the actual versions | ||
This package is an ES module and must be loaded using | ||
[an `import` or `import()` statement](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c), | ||
not `require()`. | ||
# Usage | ||
@@ -120,2 +123,4 @@ | ||
Normalize and validate Node.js versions | ||
- [`preferred-node-version`](https://github.com/ehmicky/preferred-node-version): | ||
Get the preferred Node.js version of a project or user | ||
- [`all-node-versions`](https://github.com/ehmicky/all-node-versions): List all | ||
@@ -128,8 +133,4 @@ available Node.js versions | ||
If you found a bug or would like a new feature, _don't hesitate_ to | ||
[submit an issue on GitHub](../../issues). | ||
For any question, _don't hesitate_ to [submit an issue on GitHub](../../issues). | ||
For other questions, feel free to | ||
[chat with us on Gitter](https://gitter.im/ehmicky/node-version-alias). | ||
Everyone is welcome regardless of personal background. We enforce a | ||
@@ -136,0 +137,0 @@ [Code of conduct](CODE_OF_CONDUCT.md) in order to promote a positive and |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3
163
Yes
36510
13
140
+ Added@jest/types@27.5.1(transitive)
+ Added@sindresorhus/is@4.6.0(transitive)
+ Added@types/istanbul-reports@3.0.4(transitive)
+ Added@types/yargs@16.0.9(transitive)
+ Addedall-node-versions@9.0.0(transitive)
+ Addedansi-styles@5.2.0(transitive)
+ Addedcacheable-lookup@5.0.4(transitive)
+ Addedcamelcase@6.3.0(transitive)
+ Addedcolors-option@2.0.1(transitive)
+ Addeddecompress-response@6.0.0(transitive)
+ Addedfetch-node-website@6.1.2(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedglobal-cache-dir@3.0.1(transitive)
+ Addedgot@11.8.6(transitive)
+ Addedhttp2-wrapper@1.0.3(transitive)
+ Addedis-plain-obj@4.1.0(transitive)
+ Addedjest-get-type@27.5.1(transitive)
+ Addedjest-validate@27.5.1(transitive)
+ Addedmimic-response@3.1.0(transitive)
+ Addednormalize-node-version@11.0.0(transitive)
+ Addedpretty-format@27.5.1(transitive)
+ Addedquick-lru@5.1.1(transitive)
+ Addedreact-is@17.0.2(transitive)
+ Addedresolve-alpn@1.2.1(transitive)
- Removed@jest/types@25.5.0(transitive)
- Removed@sindresorhus/is@2.1.1(transitive)
- Removed@types/istanbul-reports@1.1.2(transitive)
- Removed@types/yargs@15.0.19(transitive)
- Removedall-node-versions@8.0.0(transitive)
- Removedcacheable-lookup@2.0.1(transitive)
- Removedcamelcase@5.3.1(transitive)
- Removedchalk@3.0.0(transitive)
- Removeddecompress-response@5.0.0(transitive)
- Removedduplexer3@0.1.5(transitive)
- Removedfetch-node-website@5.0.3(transitive)
- Removedglobal-cache-dir@2.0.0(transitive)
- Removedgot@10.7.0(transitive)
- Removedjest-get-type@25.2.6(transitive)
- Removedjest-validate@25.5.0(transitive)
- Removedmimic-response@2.1.0(transitive)
- Removednormalize-node-version@10.0.0(transitive)
- Removedp-event@4.2.0(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedp-timeout@3.2.0(transitive)
- Removedpretty-format@25.5.0(transitive)
- Removedreact-is@16.13.1(transitive)
- Removedto-readable-stream@2.1.0(transitive)
- Removedtype-fest@0.10.0(transitive)
Updatedall-node-versions@^9.0.0
Updatedjest-validate@^27.0.2
Updatedsemver@^7.3.5