fetch-node-website
Advanced tools
Comparing version
@@ -5,17 +5,6 @@ import{env}from"process"; | ||
export const getMirrorEnv=function(){ | ||
const mirrorName=MIRRORS.find(isDefinedEnv); | ||
if(mirrorName===undefined){ | ||
return{}; | ||
} | ||
const mirror=env[mirrorName]; | ||
return{mirror}; | ||
export const getDefaultMirror=function(){var _MIRRORS$map$find; | ||
return(_MIRRORS$map$find=MIRRORS.map(getEnv).find(Boolean))!==null&&_MIRRORS$map$find!==void 0?_MIRRORS$map$find:DEFAULT_MIRROR; | ||
}; | ||
const isDefinedEnv=function(name){ | ||
return env[name]!==undefined&&env[name].trim()!==""; | ||
}; | ||
const MIRRORS=[ | ||
@@ -26,2 +15,9 @@ "NODE_MIRROR", | ||
"NODIST_NODE_MIRROR"]; | ||
const getEnv=function(name){ | ||
return env[name]; | ||
}; | ||
const DEFAULT_MIRROR="https://nodejs.org/dist"; | ||
//# sourceMappingURL=mirror.js.map |
@@ -1,5 +0,4 @@ | ||
import{excludeKeys}from"filter-obj"; | ||
import{validate}from"jest-validate"; | ||
import isPlainObj from"is-plain-obj"; | ||
import{getMirrorEnv}from"./mirror.js"; | ||
import{getDefaultMirror}from"./mirror.js"; | ||
@@ -9,28 +8,29 @@ | ||
validateBasic(path,opts); | ||
validate(opts,{exampleConfig:EXAMPLE_OPTS}); | ||
const optsA=excludeKeys(opts,isUndefined); | ||
const mirrorEnv=getMirrorEnv(); | ||
const optsB={...DEFAULT_OPTS,...mirrorEnv,...optsA}; | ||
return optsB; | ||
const{progress=false,mirror=getDefaultMirror()}=opts; | ||
validateProgress(progress); | ||
validateMirror(mirror); | ||
return{progress,mirror}; | ||
}; | ||
const validateBasic=function(path){ | ||
const validateBasic=function(path,opts){ | ||
if(typeof path!=="string"||path.trim()===""){ | ||
throw new TypeError(`Path must be a non-empty string: ${path}`); | ||
} | ||
if(!isPlainObj(opts)){ | ||
throw new TypeError(`Options must be a plain object: ${opts}`); | ||
} | ||
}; | ||
export const DEFAULT_OPTS={ | ||
progress:false, | ||
mirror:"https://nodejs.org/dist"}; | ||
const validateProgress=function(progress){ | ||
if(typeof progress!=="boolean"){ | ||
throw new TypeError(`Option "progress" must be a boolean: ${progress}`); | ||
} | ||
}; | ||
export const EXAMPLE_OPTS={ | ||
...DEFAULT_OPTS}; | ||
const isUndefined=function(key,value){ | ||
return value===undefined; | ||
const validateMirror=function(mirror){ | ||
if(typeof mirror!=="string"){ | ||
throw new TypeError(`Option "mirror" must be a string: ${mirror}`); | ||
} | ||
}; | ||
//# sourceMappingURL=options.js.map |
{ | ||
"name": "fetch-node-website", | ||
"version": "7.1.0", | ||
"version": "7.2.0", | ||
"type": "module", | ||
@@ -50,14 +50,13 @@ "exports": "./build/src/main.js", | ||
"cli-progress": "^3.11.2", | ||
"colors-option": "^4.2.0", | ||
"colors-option": "^4.4.0", | ||
"figures": "^5.0.0", | ||
"filter-obj": "^5.1.0", | ||
"got": "^12.1.0", | ||
"jest-validate": "^28.1.3" | ||
"got": "^12.3.1", | ||
"is-plain-obj": "^4.1.0" | ||
}, | ||
"devDependencies": { | ||
"@ehmicky/dev-tasks": "^1.0.84", | ||
"@ehmicky/dev-tasks": "^1.0.94", | ||
"@types/node": "^18.0.0", | ||
"get-stream": "^6.0.0", | ||
"sinon": "^14.0.0", | ||
"test-each": "^5.2.0" | ||
"test-each": "^5.4.1" | ||
}, | ||
@@ -64,0 +63,0 @@ "engines": { |
[](https://codecov.io/gh/ehmicky/fetch-node-website) | ||
[](https://www.npmjs.com/package/fetch-node-website) | ||
[](/src/main.d.ts) | ||
[](/src/main.d.ts) | ||
[](https://www.npmjs.com/package/fetch-node-website) | ||
[](https://twitter.com/intent/follow?screen_name=ehmicky) | ||
@@ -5,0 +5,0 @@ [](https://medium.com/@ehmicky) |
21120
0.67%5
-16.67%152
-0.65%+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated