mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 19:25:23 +00:00
Removed Promise returning into _patch; Now the catch is done when calling _patch and not inside _patch itself
This commit is contained in:
29
index.js
29
index.js
@@ -106,15 +106,14 @@ class Pass {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this._patch(this._filterOptions(this.overrides), passStructBuffer)
|
try {
|
||||||
.then(function _afterJSONParse(passFileBuffer) {
|
let patchedPass = this._patch(this._filterOptions(this.overrides), passStructBuffer);
|
||||||
manifest["pass.json"] = forge.md.sha1.create().update(passFileBuffer.toString("binary")).digest().toHex();
|
|
||||||
archive.append(passFileBuffer, { name: "pass.json" });
|
|
||||||
|
|
||||||
// no errors happened
|
manifest["pass.json"] = forge.md.sha1.create().update(patchedPass.toString("binary")).digest().toHex();
|
||||||
return passCallback(null);
|
archive.append(patchedPass, { name: "pass.json" });
|
||||||
})
|
|
||||||
.catch(err => {
|
return passCallback();
|
||||||
|
} catch (e) {
|
||||||
return passCallback({
|
return passCallback({
|
||||||
status: false,
|
status: false,
|
||||||
error: {
|
error: {
|
||||||
@@ -122,7 +121,7 @@ class Pass {
|
|||||||
ecode: 418
|
ecode: 418
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -292,12 +291,11 @@ class Pass {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
_patch(options, passBuffer) {
|
_patch(options, passBuffer) {
|
||||||
|
|
||||||
if (!options) {
|
if (!options) {
|
||||||
return Promise.resolve(passBuffer);
|
return passBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((success, reject) => {
|
|
||||||
try {
|
|
||||||
let passFile = JSON.parse(passBuffer.toString("utf8"));
|
let passFile = JSON.parse(passBuffer.toString("utf8"));
|
||||||
|
|
||||||
// "barcodes" support got introduced in iOS 9 as array of barcode.
|
// "barcodes" support got introduced in iOS 9 as array of barcode.
|
||||||
@@ -340,11 +338,7 @@ class Pass {
|
|||||||
|
|
||||||
Object.assign(passFile, options);
|
Object.assign(passFile, options);
|
||||||
|
|
||||||
return success(Buffer.from(JSON.stringify(passFile)));
|
return Buffer.from(JSON.stringify(passFile));
|
||||||
} catch(e) {
|
|
||||||
return reject(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -386,7 +380,6 @@ class Pass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((success, reject) => {
|
return new Promise((success, reject) => {
|
||||||
|
|
||||||
if (!options.model || typeof options.model !== "string") {
|
if (!options.model || typeof options.model !== "string") {
|
||||||
return reject({
|
return reject({
|
||||||
status: false,
|
status: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user