jackspeak
Advanced tools
Comparing version 2.3.1 to 2.3.2
@@ -396,2 +396,14 @@ "use strict"; | ||
/** | ||
* do not set fields as 'no-foo' if 'foo' exists and both are bools | ||
* just set foo. | ||
*/ | ||
#noNoFields(f, val, s = f) { | ||
if (!f.startsWith('no-') || typeof val !== 'boolean') | ||
return; | ||
const yes = f.substring('no-'.length); | ||
if (this.#configSet[yes]?.type === 'boolean') { | ||
throw new Error(`do not set '${s}', instead set '${yes}' as desired.`); | ||
} | ||
} | ||
/** | ||
* Validate that any arbitrary object is a valid configuration `values` | ||
@@ -405,2 +417,3 @@ * object. Useful when loading config files or other sources. | ||
for (const field in o) { | ||
this.#noNoFields(field, o[field]); | ||
const config = this.#configSet[field]; | ||
@@ -407,0 +420,0 @@ if (!config) { |
@@ -388,2 +388,14 @@ import { inspect } from 'node:util'; | ||
/** | ||
* do not set fields as 'no-foo' if 'foo' exists and both are bools | ||
* just set foo. | ||
*/ | ||
#noNoFields(f, val, s = f) { | ||
if (!f.startsWith('no-') || typeof val !== 'boolean') | ||
return; | ||
const yes = f.substring('no-'.length); | ||
if (this.#configSet[yes]?.type === 'boolean') { | ||
throw new Error(`do not set '${s}', instead set '${yes}' as desired.`); | ||
} | ||
} | ||
/** | ||
* Validate that any arbitrary object is a valid configuration `values` | ||
@@ -397,2 +409,3 @@ * object. Useful when loading config files or other sources. | ||
for (const field in o) { | ||
this.#noNoFields(field, o[field]); | ||
const config = this.#configSet[field]; | ||
@@ -399,0 +412,0 @@ if (!config) { |
{ | ||
"name": "jackspeak", | ||
"version": "2.3.1", | ||
"version": "2.3.2", | ||
"description": "A very strict and proper argument parser.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
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
246903
2307