mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 22:25:24 +00:00
_parseSettings now throws on error;
Removed async.concat for Promise.all implementation;
This commit is contained in:
15
index.js
15
index.js
@@ -579,12 +579,11 @@ class Pass {
|
|||||||
|
|
||||||
_parseSettings(options) {
|
_parseSettings(options) {
|
||||||
if (!schema.isValid(options, schema.constants.instance)) {
|
if (!schema.isValid(options, schema.constants.instance)) {
|
||||||
return Promise.reject(errors.REQS_NOT_MET);
|
throw new Error(errors.REQS_NOT_MET);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((success, reject) => {
|
|
||||||
if (!options.model || typeof options.model !== "string") {
|
if (!options.model || typeof options.model !== "string") {
|
||||||
return reject(errors.MODEL_NOT_STRING);
|
throw new Error(errors.MODEL_NOT_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.model = path.resolve(options.model) + (!!options.model && !path.extname(options.model) ? ".pass" : "");
|
this.model = path.resolve(options.model) + (!!options.model && !path.extname(options.model) ? ".pass" : "");
|
||||||
@@ -593,13 +592,10 @@ class Pass {
|
|||||||
|
|
||||||
let certPaths = Object.keys(options.certificates)
|
let certPaths = Object.keys(options.certificates)
|
||||||
.filter(v => v !== "dir")
|
.filter(v => v !== "dir")
|
||||||
.map((val) => path.resolve(typeof options.certificates[val] !== "object" ? options.certificates[val] : options.certificates[val]["keyFile"]));
|
.map((val) => readFile(path.resolve(typeof options.certificates[val] !== "object" ? options.certificates[val] : options.certificates[val]["keyFile"])));
|
||||||
|
|
||||||
async.concat(certPaths, fs.readFile, (err, contents) => {
|
|
||||||
if (err) {
|
|
||||||
return reject(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return Promise.all(certPaths).then(contents => {
|
||||||
contents.forEach(file => {
|
contents.forEach(file => {
|
||||||
let pem = this.__parsePEM(file, options.certificates.signerKey.passphrase);
|
let pem = this.__parsePEM(file, options.certificates.signerKey.passphrase);
|
||||||
if (!pem) {
|
if (!pem) {
|
||||||
@@ -608,9 +604,6 @@ class Pass {
|
|||||||
|
|
||||||
this.Certificates[pem.key] = pem.value;
|
this.Certificates[pem.key] = pem.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
return success();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user