Removed Promise returning into _patch; Now the catch is done when calling _patch and not inside _patch itself

This commit is contained in:
alexandercerutti
2018-08-03 02:38:35 +02:00
parent 1d1a4cd9c5
commit 565916c65d

View File

@@ -106,15 +106,14 @@ class Pass {
});
}
this._patch(this._filterOptions(this.overrides), passStructBuffer)
.then(function _afterJSONParse(passFileBuffer) {
manifest["pass.json"] = forge.md.sha1.create().update(passFileBuffer.toString("binary")).digest().toHex();
archive.append(passFileBuffer, { name: "pass.json" });
try {
let patchedPass = this._patch(this._filterOptions(this.overrides), passStructBuffer);
// no errors happened
return passCallback(null);
})
.catch(err => {
manifest["pass.json"] = forge.md.sha1.create().update(patchedPass.toString("binary")).digest().toHex();
archive.append(patchedPass, { name: "pass.json" });
return passCallback();
} catch (e) {
return passCallback({
status: false,
error: {
@@ -122,7 +121,7 @@ class Pass {
ecode: 418
}
});
});
}
});
});
@@ -292,12 +291,11 @@ class Pass {
*/
_patch(options, passBuffer) {
if (!options) {
return Promise.resolve(passBuffer);
return passBuffer;
}
return new Promise((success, reject) => {
try {
let passFile = JSON.parse(passBuffer.toString("utf8"));
// "barcodes" support got introduced in iOS 9 as array of barcode.
@@ -340,11 +338,7 @@ class Pass {
Object.assign(passFile, options);
return success(Buffer.from(JSON.stringify(passFile)));
} catch(e) {
return reject(e);
}
});
return Buffer.from(JSON.stringify(passFile));
}
/**
@@ -386,7 +380,6 @@ class Pass {
}
return new Promise((success, reject) => {
if (!options.model || typeof options.model !== "string") {
return reject({
status: false,