colors-option
Advanced tools
Comparing version 4.3.1 to 4.4.0
@@ -16,3 +16,2 @@ import{Chalk}from"chalk"; | ||
const{colors,stream,chalkOpts}=getOpts(opts); | ||
const level=getLevel(colors,stream); | ||
@@ -29,16 +28,7 @@ const chalk=new Chalk({...chalkOpts,level}); | ||
const terminalLevel=getTerminalLevel(stream); | ||
if(colors===undefined){ | ||
return terminalLevel; | ||
} | ||
return Math.max(terminalLevel,1); | ||
return colors===undefined?terminalLevel:Math.max(terminalLevel,1); | ||
}; | ||
const getTerminalLevel=function(stream){ | ||
if(!stream.isTTY){ | ||
return 0; | ||
} | ||
return DEPTH_TO_LEVEL[stream.getColorDepth()]; | ||
return stream.isTTY?DEPTH_TO_LEVEL[stream.getColorDepth()]:0; | ||
}; | ||
@@ -45,0 +35,0 @@ |
import{stdout}from"process"; | ||
import{Stream}from"stream"; | ||
import{excludeKeys}from"filter-obj"; | ||
import isPlainObj from"is-plain-obj"; | ||
import{validate}from"jest-validate"; | ||
export const getOpts=function(opts={}){ | ||
validateOpts(opts); | ||
const optsA=excludeKeys(opts,isUndefined); | ||
const{ | ||
colors:colorsA, | ||
stream, | ||
...chalkOpts}= | ||
{ | ||
...DEFAULT_OPTS, | ||
...optsA}; | ||
return{colors:colorsA,stream,chalkOpts}; | ||
}; | ||
const validateOpts=function(opts){ | ||
validateBasicOpts(opts); | ||
validate(opts,{exampleConfig:EXAMPLE_OPTS,recursiveDenylist:["stream"]}); | ||
validateStream(opts); | ||
const{colors,stream=stdout,...chalkOpts}=opts; | ||
validateColors(colors); | ||
validateStream(stream); | ||
return{colors,stream,chalkOpts}; | ||
}; | ||
@@ -35,19 +21,13 @@ | ||
const validateStream=function({stream}){ | ||
if(stream!==undefined&&!(stream instanceof Stream)){ | ||
throw new TypeError(`"stream" option must be a stream: ${stream}`); | ||
const validateColors=function(colors){ | ||
if(colors!==undefined&&typeof colors!=="boolean"){ | ||
throw new TypeError(`"colors" option must be a boolean: ${colors}`); | ||
} | ||
}; | ||
const isUndefined=function(key,value){ | ||
return value===undefined; | ||
const validateStream=function(stream){ | ||
if(!(stream instanceof Stream)){ | ||
throw new TypeError(`"stream" option must be a stream: ${stream}`); | ||
} | ||
}; | ||
const DEFAULT_OPTS={ | ||
stream:stdout}; | ||
const EXAMPLE_OPTS={ | ||
...DEFAULT_OPTS, | ||
colors:true}; | ||
//# sourceMappingURL=options.js.map |
{ | ||
"name": "colors-option", | ||
"version": "4.3.1", | ||
"version": "4.4.0", | ||
"type": "module", | ||
@@ -50,5 +50,3 @@ "exports": "./build/src/main.js", | ||
"chalk": "^5.0.1", | ||
"filter-obj": "^5.1.0", | ||
"is-plain-obj": "^4.1.0", | ||
"jest-validate": "^29.0.1" | ||
"is-plain-obj": "^4.1.0" | ||
}, | ||
@@ -55,0 +53,0 @@ "devDependencies": { |
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
2
9369
79
- Removedfilter-obj@^5.1.0
- Removedjest-validate@^29.0.1
- Removed@jest/schemas@29.6.3(transitive)
- Removed@jest/types@29.6.3(transitive)
- Removed@sinclair/typebox@0.27.8(transitive)
- Removed@types/istanbul-lib-coverage@2.0.6(transitive)
- Removed@types/istanbul-lib-report@3.0.3(transitive)
- Removed@types/istanbul-reports@3.0.4(transitive)
- Removed@types/node@22.9.0(transitive)
- Removed@types/yargs@17.0.33(transitive)
- Removed@types/yargs-parser@21.0.3(transitive)
- Removedansi-styles@4.3.05.2.0(transitive)
- Removedcamelcase@6.3.0(transitive)
- Removedchalk@4.1.2(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removedfilter-obj@5.1.0(transitive)
- Removedhas-flag@4.0.0(transitive)
- Removedjest-get-type@29.6.3(transitive)
- Removedjest-validate@29.7.0(transitive)
- Removedleven@3.1.0(transitive)
- Removedpretty-format@29.7.0(transitive)
- Removedreact-is@18.3.1(transitive)
- Removedsupports-color@7.2.0(transitive)
- Removedundici-types@6.19.8(transitive)