read-config-file
Advanced tools
Comparing version 1.0.5 to 1.1.0
import { Lazy } from "lazy-val"; | ||
import { ErrorObject } from "ajv"; | ||
export declare function readConfig<T>(configFile: string, projectDir?: string, log?: (message: string) => void): Promise<T>; | ||
@@ -18,1 +19,2 @@ export declare function findAndReadConfig<T>(request: ReadConfigRequest): Promise<T | null>; | ||
export declare function loadParentConfig<T>(request: ReadConfigRequest, spec: string): Promise<T>; | ||
export declare function validateConfig(config: any, scheme: Lazy<any>, errorMessage: (error: string, errors: Array<ErrorObject>) => string): Promise<void>; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.loadParentConfig = exports.getConfig = exports.loadConfig = exports.findAndReadConfig = exports.readConfig = undefined; | ||
exports.validateConfig = exports.loadParentConfig = exports.getConfig = exports.loadConfig = exports.findAndReadConfig = exports.readConfig = undefined; | ||
@@ -115,2 +115,24 @@ var _bluebirdLst; | ||
})(); | ||
let validateConfig = exports.validateConfig = (() => { | ||
var _ref6 = (0, (_bluebirdLst || _load_bluebirdLst()).coroutine)(function* (config, scheme, errorMessage) { | ||
const ajv = new (_ajv || _load_ajv()).default({ | ||
allErrors: true, | ||
coerceTypes: true, | ||
verbose: true, | ||
errorDataPath: "configuration" | ||
}); | ||
ajv.addMetaSchema(require("ajv/lib/refs/json-schema-draft-04.json")); | ||
require("ajv-keywords")(ajv, ["typeof"]); | ||
const schema = yield scheme.value; | ||
const validator = ajv.compile(schema); | ||
if (!validator(config)) { | ||
throw new Error(errorMessage((0, (_ajvErrorNormalizer || _load_ajvErrorNormalizer()).normaliseErrorMessages)(validator.errors, schema), validator.errors)); | ||
} | ||
}); | ||
return function validateConfig(_x11, _x12, _x13) { | ||
return _ref6.apply(this, arguments); | ||
}; | ||
})(); | ||
//# sourceMappingURL=main.js.map | ||
@@ -142,2 +164,16 @@ | ||
var _ajv; | ||
function _load_ajv() { | ||
return _ajv = _interopRequireDefault(require("ajv")); | ||
} | ||
var _ajvErrorNormalizer; | ||
function _load_ajvErrorNormalizer() { | ||
return _ajvErrorNormalizer = require("./ajvErrorNormalizer"); | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
@@ -144,0 +180,0 @@ |
{ | ||
"name": "read-config-file", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"main": "out/main.js", | ||
@@ -18,2 +18,4 @@ "author": "Vladimir Krivosheev", | ||
"dependencies": { | ||
"ajv": "^5.2.2", | ||
"ajv-keywords": "^2.1.0", | ||
"bluebird-lst": "^1.0.3", | ||
@@ -26,6 +28,6 @@ "fs-extra-p": "^4.4.0", | ||
"devDependencies": { | ||
"@types/js-yaml": "^3.9.0", | ||
"@types/node": "^8.0.20", | ||
"@types/js-yaml": "^3.9.1", | ||
"@types/node": "^8.0.25", | ||
"babel-preset-ts-node4-bluebird": "^0.1.0", | ||
"ts-babel": "^3.2.1", | ||
"ts-babel": "^4.1.3", | ||
"typescript": "^2.4.2" | ||
@@ -32,0 +34,0 @@ }, |
Sorry, the diff of this file is not supported yet
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
51118
11
429
7
+ Addedajv@^5.2.2
+ Addedajv-keywords@^2.1.0
+ Addedajv@5.5.2(transitive)
+ Addedajv-keywords@2.1.1(transitive)
+ Addedco@4.6.0(transitive)
+ Addedfast-deep-equal@1.1.0(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedjson-schema-traverse@0.3.1(transitive)