Socket
Socket
Sign inDemoInstall

get-node

Package Overview
Dependencies
96
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 13.5.0 to 13.6.0

build/src/main.d.ts

7

build/src/arch.js
import{platform}from"node:process";
export const validateArch=function(arch){
export const validateArch=(arch)=>{
if(arch in PLATFORMS){

@@ -17,3 +17,3 @@ return;

export const getArch=function(arch){
export const getArch=(arch)=>{
/* c8 ignore start */

@@ -37,3 +37,4 @@ if(platform==="aix"){

x32:"x86",
x64:"x64"};
x64:"x64"
};
//# sourceMappingURL=arch.js.map

@@ -14,8 +14,3 @@ import{platform}from"node:process";

export const downloadGz=async function({
version,
arch,
tmpFile,
fetchOpts})
{
export const downloadGz=async({version,arch,tmpFile,fetchOpts})=>{
const{response,checksumError}=await fetchNodeUrl(

@@ -22,0 +17,0 @@ version,

@@ -11,8 +11,3 @@ import{platform}from"node:process";

export const downloadRuntime=function({
version,
tmpFile,
arch,
fetchOpts})
{
export const downloadRuntime=({version,tmpFile,arch,fetchOpts})=>{
if(platform==="win32"){

@@ -38,8 +33,8 @@ return downloadWindowsNode({version,tmpFile,arch,fetchOpts});

export const downloadWindowsNode=async function({
export const downloadWindowsNode=async({
version,
tmpFile,
arch,
fetchOpts})
{
fetchOpts
})=>{
if(await shouldUse7z(version)){

@@ -57,8 +52,8 @@ return download7z({version,tmpFile,arch,fetchOpts});

export const downloadUnixNode=async function({
export const downloadUnixNode=async({
version,
tmpFile,
arch,
fetchOpts})
{
fetchOpts
})=>{
if(await shouldUseXz(version)){

@@ -65,0 +60,0 @@ return downloadXz({version,tmpFile,arch,fetchOpts});

@@ -23,18 +23,14 @@ import{createWriteStream}from"node:fs";

export const shouldUse7z=function(version){
return versionHas7z(version)&&has7zBinary();
};
export const shouldUse7z=(version)=>versionHas7z(version)&&has7zBinary();
const versionHas7z=function(version){
return semver.satisfies(version,P7Z_VERSION_RANGE);
};
const versionHas7z=(version)=>semver.satisfies(version,P7Z_VERSION_RANGE);
const P7Z_VERSION_RANGE="^4.5.0 || >=6.2.1";
const mHas7zBinary=async function(){
const mHas7zBinary=async()=>{
const{failed}=await execa("7z",{
reject:false,
stdio:"ignore",
env:getEnv()});
env:getEnv()
});
return!failed;

@@ -48,8 +44,3 @@ };

export const download7z=async function({
version,
tmpFile,
arch,
fetchOpts})
{
export const download7z=async({version,tmpFile,arch,fetchOpts})=>{
const filepath=get7zFilepath(version,arch);

@@ -72,5 +63,5 @@ const tmp7zFile=`${tmpFile}.7z`;

buffer:false,
env:getEnv()});
env:getEnv()
});
const promise=pPipeline(stdout,writeNodeBinary(tmpFile));

@@ -87,8 +78,6 @@

const get7zFilepath=function(version,arch){
return`node-v${version}-win-${arch}`;
};
const get7zFilepath=(version,arch)=>`node-v${version}-win-${arch}`;
const getEnv=function(){
const getEnv=()=>{
const path=`${env[PATH_KEY]}${delimiter}${P7Z_PATH}`;

@@ -101,3 +90,3 @@ return{Path:path,PATH:path};

const cleanup=async function(tmp7zFile,cancel){
const cleanup=async(tmp7zFile,cancel)=>{
await unlink(tmp7zFile);

@@ -104,0 +93,0 @@ cancel();

@@ -13,8 +13,3 @@ import{pipeline}from"node:stream";

export const downloadRaw=async function({
version,
tmpFile,
arch,
fetchOpts})
{
export const downloadRaw=async({version,tmpFile,arch,fetchOpts})=>{
const filepath=getFilepath(version,arch);

@@ -34,3 +29,3 @@ const{response,checksumError}=await fetchNodeUrl(

const getFilepath=function(version,arch){
const getFilepath=(version,arch)=>{
if(semver.gte(version,NEW_URL_VERSION)){

@@ -37,0 +32,0 @@ return`win-${arch}/node.exe`;

@@ -6,11 +6,8 @@ import{rename,rm}from"node:fs/promises";

export const untar=function(tmpFile){
return tarExtract(tmpFile,{ignore:shouldExclude,strip:2});
};
export const untar=(tmpFile)=>
tarExtract(tmpFile,{ignore:shouldExclude,strip:2});
const shouldExclude=function(path){
return!path.endsWith("/node");
};
const shouldExclude=(path)=>!path.endsWith("/node");

@@ -20,3 +17,3 @@

export const moveTar=async function(tmpFile){
export const moveTar=async(tmpFile)=>{
const intermediateFile=`${tmpFile}-${Math.random()}`;

@@ -23,0 +20,0 @@ await rename(`${tmpFile}/node`,intermediateFile);

@@ -21,18 +21,15 @@ import{cpus}from"node:os";

export const shouldUseXz=function(version){
return versionHasXz(version)&&platform!=="aix"&&hasXzBinary();
};
export const shouldUseXz=(version)=>
versionHasXz(version)&&platform!=="aix"&&hasXzBinary();
const versionHasXz=function(version){
return semver.satisfies(version,XZ_VERSION_RANGE);
};
const versionHasXz=(version)=>semver.satisfies(version,XZ_VERSION_RANGE);
const XZ_VERSION_RANGE="^0.10.42 || >=0.12.10";
const mHasXzBinary=async function(){
const mHasXzBinary=async()=>{
const{failed}=await execaCommand("xz --version",{
reject:false,
stdio:"ignore"});
stdio:"ignore"
});
return!failed;

@@ -43,8 +40,3 @@ };

export const downloadXz=async function({
version,
tmpFile,
arch,
fetchOpts})
{
export const downloadXz=async({version,tmpFile,arch,fetchOpts})=>{
const{response,checksumError}=await fetchNodeUrl(

@@ -61,5 +53,5 @@ version,

stderr:"ignore",
buffer:false});
buffer:false
});
const promise=pPipeline(stdout,untar(tmpFile));

@@ -66,0 +58,0 @@

@@ -14,5 +14,4 @@ import{pipeline}from"node:stream";

export const shouldUseZip=function(version){
return semver.satisfies(version,ZIP_VERSION_RANGE);
};
export const shouldUseZip=(version)=>
semver.satisfies(version,ZIP_VERSION_RANGE);

@@ -25,8 +24,3 @@ const ZIP_VERSION_RANGE="^4.5.0 || >=6.2.1";

export const downloadZip=async function({
version,
tmpFile,
arch,
fetchOpts})
{
export const downloadZip=async({version,tmpFile,arch,fetchOpts})=>{
const filepath=getZipFilepath(version,arch);

@@ -47,7 +41,5 @@ const{response,checksumError}=await fetchNodeUrl(

const getZipFilepath=function(version,arch){
return`node-v${version}-win-${arch}`;
};
const getZipFilepath=(version,arch)=>`node-v${version}-win-${arch}`;
const getZipStream=async function(zipContent,filepath){
const getZipStream=async(zipContent,filepath)=>{
const archive=await jszip.loadAsync(zipContent,JSZIP_OPTIONS);

@@ -54,0 +46,0 @@ const file=archive.file(`${filepath}/node.exe`);

@@ -10,8 +10,8 @@ import{createHash}from"node:crypto";

export const checkChecksum=async function({
export const checkChecksum=async({
version,
filepath,
response,
fetchOpts})
{
fetchOpts
})=>{
try{

@@ -40,3 +40,3 @@ const[expectedChecksum,actualChecksum]=await Promise.all([

const getExpectedChecksum=async function(version,filepath,fetchOpts){
const getExpectedChecksum=async(version,filepath,fetchOpts)=>{
const checksumLines=await getChecksumLines(version,fetchOpts);

@@ -50,3 +50,3 @@ const[expectedChecksum]=checksumLines.

const getChecksumLines=async function(version,fetchOpts){
const getChecksumLines=async(version,fetchOpts)=>{

@@ -61,4 +61,4 @@

...fetchOpts,
progress:false});
progress:false
});
const checksumLines=await getStream(response);

@@ -68,5 +68,4 @@ return checksumLines;

const parseChecksumLine=function(checksumLine){
return checksumLine.trim().split(CHECKSUM_LINE_DELIMITER);
};
const parseChecksumLine=(checksumLine)=>
checksumLine.trim().split(CHECKSUM_LINE_DELIMITER);

@@ -76,3 +75,3 @@ const CHECKSUM_LINE_DELIMITER=/\s+/u;

const getActualChecksum=async function(response){
const getActualChecksum=async(response)=>{
const hashStream=response.pipe(createHash("sha256",{encoding:"hex"}));

@@ -79,0 +78,0 @@ const actualChecksum=await getStream(hashStream);

@@ -14,3 +14,3 @@ import{rm}from"node:fs/promises";

export const download=async function({version,output,arch,fetchOpts}){
export const download=async({version,output,arch,fetchOpts})=>{
const archA=getArch(arch);

@@ -46,3 +46,3 @@ const nodePath=join(output,version,archA,NODE_FILENAME);

const downloadFile=async function({version,nodePath,arch,fetchOpts}){
const downloadFile=async({version,nodePath,arch,fetchOpts})=>{
const tmpFile=await tmpName({prefix:`get-node-${version}-${arch}`});

@@ -58,3 +58,3 @@

const tmpDownload=async function({version,tmpFile,arch,fetchOpts}){
const tmpDownload=async({version,tmpFile,arch,fetchOpts})=>{
const checksumError=await safeDownload({

@@ -64,3 +64,4 @@ version,

arch,
fetchOpts});
fetchOpts
});

@@ -70,3 +71,2 @@

if(checksumError!==undefined){

@@ -77,3 +77,3 @@ throw new Error(await checksumError);

const safeDownload=async function({version,tmpFile,arch,fetchOpts}){
const safeDownload=async({version,tmpFile,arch,fetchOpts})=>{
try{

@@ -88,8 +88,8 @@ return await downloadRuntime({version,tmpFile,arch,fetchOpts});

const getDownloadError=function({
const getDownloadError=({
message,
version,
arch,
fetchOpts:{mirror}})
{
fetchOpts:{mirror}
})=>{
if(message.includes("getaddrinfo")){

@@ -108,3 +108,3 @@ return`Could not connect to ${mirror}`;

const moveTmpFile=async function(tmpFile,nodePath){
const moveTmpFile=async(tmpFile,nodePath)=>{

@@ -121,5 +121,5 @@ if(await pathExists(nodePath)){

const cleanTmpFile=async function(tmpFile){
const cleanTmpFile=async(tmpFile)=>{
await rm(tmpFile,{force:true,recursive:true});
};
//# sourceMappingURL=download.js.map

@@ -10,3 +10,3 @@ import{once}from"node:events";

export const fetchNodeUrl=async function(version,filepath,fetchOpts){
export const fetchNodeUrl=async(version,filepath,fetchOpts)=>{
const response=await fetchNodeWebsite(`v${version}/${filepath}`,fetchOpts);

@@ -17,4 +17,4 @@ const checksumError=checkChecksum({

response,
fetchOpts});
fetchOpts
});
return{response,checksumError};

@@ -25,7 +25,7 @@ };

export const promiseOrFetchError=async function(promise,response){
export const promiseOrFetchError=async(promise,response)=>{
await Promise.race([promise,throwOnFetchError(response)]);
};
const throwOnFetchError=async function(response){
const throwOnFetchError=async(response)=>{
const[error]=await once(response,"error");

@@ -36,7 +36,6 @@ throw error;

export const writeNodeBinary=function(tmpFile){
return createWriteStream(tmpFile,{mode:NODE_MODE});
};
export const writeNodeBinary=(tmpFile)=>
createWriteStream(tmpFile,{mode:NODE_MODE});
const NODE_MODE=493;
//# sourceMappingURL=fetch.js.map

@@ -6,3 +6,3 @@ import{download}from"./download.js";

export default async function getNode(versionRange,opts){
const getNode=async(versionRange,opts)=>{
const{

@@ -14,12 +14,14 @@ versionRange:versionRangeA,

nodeVersionAliasOpts,
fetchOpts}=
await getOpts(versionRange,opts);
fetchOpts
}=await getOpts(versionRange,opts);
const version=await getVersion({
versionRange:versionRangeA,
preferredNodeOpts,
nodeVersionAliasOpts});
nodeVersionAliasOpts
});
const nodePath=await download({version,output,arch,fetchOpts});
return{version,path:nodePath};
}
};
export default getNode;
//# sourceMappingURL=main.js.map

@@ -11,5 +11,5 @@ import{arch as processArch}from"node:process";

export const getOpts=async function(
export const getOpts=async(
versionRange=DEFAULT_VERSION_RANGE,
opts={})
opts={})=>
{

@@ -28,4 +28,4 @@ validateVersionRange(versionRange);

mirror,
progress=false}=
opts;
progress=false
}=opts;

@@ -44,5 +44,5 @@ validateOutput(output);

nodeVersionAliasOpts,
fetchOpts};
fetchOpts
};
};
//# sourceMappingURL=options.js.map
import globalCacheDir from"global-cache-dir";
export const getDefaultOutput=async function(){
return await globalCacheDir(CACHE_DIR);
};
export const getDefaultOutput=async()=>await globalCacheDir(CACHE_DIR);

@@ -11,3 +9,3 @@ const CACHE_DIR="nve";

export const validateOutput=function(output){
export const validateOutput=(output)=>{
if(typeof output!=="string"){

@@ -14,0 +12,0 @@ throw new TypeError(`Option "output" must be a string: ${output}`);

@@ -11,3 +11,3 @@ import{version as processVersion}from"node:process";

export const validateVersionRange=function(versionRange){
export const validateVersionRange=(versionRange)=>{
if(typeof versionRange!=="string"){

@@ -30,12 +30,12 @@ throw new TypeError(`Node version range must be a string: ${versionRange}`);

export const getVersion=async function({
export const getVersion=async({
versionRange,
preferredNodeOpts,
nodeVersionAliasOpts})
{
nodeVersionAliasOpts
})=>{
const version=await resolveVersion({
versionRange,
preferredNodeOpts,
nodeVersionAliasOpts});
nodeVersionAliasOpts
});
checkVersion(version);

@@ -45,7 +45,7 @@ return version;

const resolveVersion=function({
const resolveVersion=({
versionRange,
preferredNodeOpts,
nodeVersionAliasOpts})
{
nodeVersionAliasOpts
})=>{
if(versionRange==="global"){

@@ -62,3 +62,3 @@ return getPreferredVersion({...preferredNodeOpts,global:true});

const getPreferredVersion=async function(preferredNodeOpts){
const getPreferredVersion=async(preferredNodeOpts)=>{
const{version}=await preferredNodeVersion(preferredNodeOpts);

@@ -75,3 +75,3 @@

const checkVersion=function(version){
const checkVersion=(version)=>{
if(semver.lt(version,MINIMUM_VERSION)){

@@ -78,0 +78,0 @@ throw new Error(

{
"name": "get-node",
"version": "13.5.0",
"version": "13.6.0",
"type": "module",
"exports": {
"types": "./build/types/main.d.ts",
"types": "./build/src/main.d.ts",
"default": "./build/src/main.js"
},
"main": "./build/src/main.js",
"types": "./build/types/main.d.ts",
"types": "./build/src/main.d.ts",
"files": [
"build/src/**/*.{js,json}",
"build/types/**/*.d.ts"
"build/src/**/*.{js,json,d.ts}",
"!build/src/**/*.test.js",
"!build/src/{helpers,fixtures}"
],

@@ -50,10 +51,9 @@ "sideEffects": false,

"directories": {
"lib": "src",
"test": "test"
"lib": "src"
},
"dependencies": {
"execa": "^6.1.0",
"execa": "^7.0.0",
"fetch-node-website": "^7.3.0",
"get-stream": "^6.0.0",
"global-cache-dir": "^4.3.1",
"global-cache-dir": "^4.4.0",
"is-plain-obj": "^4.1.0",

@@ -63,7 +63,7 @@ "jszip": "^3.10.1",

"move-file": "^3.0.0",
"node-version-alias": "^3.4.0",
"node-version-alias": "^3.4.1",
"path-exists": "^5.0.0",
"path-key": "^4.0.0",
"preferred-node-version": "^3.5.0",
"semver": "^7.3.7",
"preferred-node-version": "^3.6.0",
"semver": "^7.3.8",
"tar-fs": "^2.1.1",

@@ -73,7 +73,7 @@ "tmp-promise": "^3.0.3"

"devDependencies": {
"@ehmicky/dev-tasks": "^1.0.102",
"@types/node": "^17.0.31",
"@ehmicky/dev-tasks": "^2.0.60",
"@types/node": "^18.11.16",
"is-ci": "^3.0.1",
"sinon": "^14.0.0",
"test-each": "^5.5.0"
"sinon": "^15.0.1",
"test-each": "^5.7.1"
},

@@ -80,0 +80,0 @@ "engines": {

[![Node](https://img.shields.io/badge/-Node.js-808080?logo=node.js&colorA=404040&logoColor=66cc33)](https://www.npmjs.com/package/get-node)
[![TypeScript](https://img.shields.io/badge/-Typed-808080?logo=typescript&colorA=404040&logoColor=0096ff)](/types/main.d.ts)
[![TypeScript](https://img.shields.io/badge/-Typed-808080?logo=typescript&colorA=404040&logoColor=0096ff)](/src/main.d.ts)
[![Codecov](https://img.shields.io/badge/-Tested%20100%25-808080?logo=codecov&colorA=404040)](https://codecov.io/gh/ehmicky/get-node)
[![Twitter](https://img.shields.io/badge/-Twitter-808080.svg?logo=twitter&colorA=404040)](https://twitter.com/intent/follow?screen_name=ehmicky)
[![Mastodon](https://img.shields.io/badge/-Mastodon-808080.svg?logo=mastodon&colorA=404040&logoColor=9590F9)](https://fosstodon.org/@ehmicky)
[![Medium](https://img.shields.io/badge/-Medium-808080.svg?logo=medium&colorA=404040)](https://medium.com/@ehmicky)

@@ -12,2 +12,12 @@

# Hire me
Please
[reach out](https://www.linkedin.com/feed/update/urn:li:activity:7018596298127781890/)
if you're looking for a Node.js API or CLI engineer (10 years of experience).
Most recently I have been [Netlify Build](https://github.com/netlify/build)'s
and [Netlify Plugins](https://www.netlify.com/products/build/plugins/)'
technical lead for 2.5 years. I am available for full-time remote positions in
either US or EU time zones.
# Features

@@ -108,3 +118,5 @@

[an `import` or `import()` statement](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c),
not `require()`.
not `require()`. If TypeScript is used, it must be configured to
[output ES modules](https://www.typescriptlang.org/docs/handbook/esm-node.html),
not CommonJS.

@@ -264,3 +276,3 @@ To use this module as a CLI instead, please check

<tr>
<td align="center"><a href="https://twitter.com/ehmicky"><img src="https://avatars2.githubusercontent.com/u/8136211?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ehmicky</b></sub></a><br /><a href="https://github.com/ehmicky/get-node/commits?author=ehmicky" title="Code">💻</a> <a href="#design-ehmicky" title="Design">🎨</a> <a href="#ideas-ehmicky" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/ehmicky/get-node/commits?author=ehmicky" title="Documentation">📖</a></td>
<td align="center"><a href="https://fosstodon.org/@ehmicky"><img src="https://avatars2.githubusercontent.com/u/8136211?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ehmicky</b></sub></a><br /><a href="https://github.com/ehmicky/get-node/commits?author=ehmicky" title="Code">💻</a> <a href="#design-ehmicky" title="Design">🎨</a> <a href="#ideas-ehmicky" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/ehmicky/get-node/commits?author=ehmicky" title="Documentation">📖</a></td>
<td align="center"><a href="https://tunnckoCore.com"><img src="https://avatars3.githubusercontent.com/u/5038030?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Charlike Mike Reagent</b></sub></a><br /><a href="https://github.com/ehmicky/get-node/issues?q=author%3AtunnckoCore" title="Bug reports">🐛</a></td>

@@ -267,0 +279,0 @@ <td align="center"><a href="http://instagram.com/private.number_"><img src="https://avatars.githubusercontent.com/u/1075694?v=4?s=100" width="100px;" alt=""/><br /><sub><b>hiroki osame</b></sub></a><br /><a href="https://github.com/ehmicky/get-node/commits?author=privatenumber" title="Code">💻</a> <a href="https://github.com/ehmicky/get-node/commits?author=privatenumber" title="Tests">⚠️</a> <a href="#ideas-privatenumber" title="Ideas, Planning, & Feedback">🤔</a></td>

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc