Skip to content

Commit

Permalink
fix(setGlobalConfig): add to index; minor improvements (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed Jan 15, 2022
1 parent f94724a commit 464f26f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 0 additions & 4 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
"type": "boolean"
}
},
"required": [
"logErrors",
"logOptionsErrors"
],
"additionalProperties": false
},
"AutocResultSet": {
Expand Down
4 changes: 3 additions & 1 deletion src/index-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import yahooFinanceFetch from "./lib/yahooFinanceFetch.js";
import moduleExec from "./lib/moduleExec.js";
import options from "./lib/options.js";
import errors from "./lib/errors.js";
import setGlobalConfig from "./lib/setGlobalConfig.js";

// modules
import autoc from "./modules/autoc.js";
Expand All @@ -26,8 +27,9 @@ export default {
_moduleExec: moduleExec,
_opts: options,

// errors
// common
errors,
setGlobalConfig,

// modules,
autoc,
Expand Down
8 changes: 4 additions & 4 deletions src/lib/validateAndCoerceTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ export function resolvePath(obj: any, instancePath: string) {
}

export interface ValidationOptions {
logErrors: boolean;
logOptionsErrors: boolean;
logErrors?: boolean;
logOptionsErrors?: boolean;
}

export interface ValidateParams {
Expand Down Expand Up @@ -227,7 +227,7 @@ function validate({
error.data = resolvePath(object, error.instancePath);
});

if (options.logErrors) {
if (options.logErrors === true) {
const title = encodeURIComponent("Failed validation: " + schemaKey);
console.log(
"The following result did not validate with schema: " + schemaKey
Expand Down Expand Up @@ -258,7 +258,7 @@ see https://github.com/gadicc/node-yahoo-finance2/tree/devel/docs/validation.md.
errors: validator.errors,
});
} /* if (type === 'options') */ else {
if (options.logOptionsErrors) {
if (options.logOptionsErrors === true) {
console.error(
`[yahooFinance.${source}] Invalid options ("${schemaKey}")`
);
Expand Down

0 comments on commit 464f26f

Please sign in to comment.