mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 18:25:24 +00:00
Minor improvements
This commit is contained in:
42
src/pass.js
42
src/pass.js
@@ -58,9 +58,7 @@ class Pass {
|
|||||||
// May have not used this catch but ENOENT error is not enough self-explanatory
|
// May have not used this catch but ENOENT error is not enough self-explanatory
|
||||||
// in the case of internal usage ()
|
// in the case of internal usage ()
|
||||||
if (err.code && err.code === "ENOENT") {
|
if (err.code && err.code === "ENOENT") {
|
||||||
let eMessage = formatError("MODEL_NOT_FOUND", this.model);
|
throw new Error(formatError("MODEL_NOT_FOUND", this.model));
|
||||||
|
|
||||||
throw new Error(eMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(err);
|
throw new Error(err);
|
||||||
@@ -70,29 +68,27 @@ class Pass {
|
|||||||
return [filesList, [], []];
|
return [filesList, [], []];
|
||||||
}
|
}
|
||||||
|
|
||||||
let buffersPromise = [
|
let buffersPromise = this._remoteResources.map((r) => {
|
||||||
...this._remoteResources.map((r) =>
|
return got(r[0], { encoding: null })
|
||||||
got(r[0], { encoding: null })
|
.then(response => {
|
||||||
.then(response => {
|
loadDebug(`Picture MIME-type: ${response.headers["content-type"]}`);
|
||||||
loadDebug(`Picture MIME-type: ${response.headers["content-type"]}`);
|
|
||||||
|
|
||||||
if (!Buffer.isBuffer(response.body)) {
|
if (!Buffer.isBuffer(response.body)) {
|
||||||
throw "NOTABUFFER";
|
throw "NOTABUFFER";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!response.headers["content-type"].includes("image/")) {
|
if (!response.headers["content-type"].includes("image/")) {
|
||||||
throw "NOTAPICTURE";
|
throw "NOTAPICTURE";
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.body;
|
return response.body;
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
loadDebug(`Was not able to fetch resource ${r[1]}. Error: ${e}`);
|
loadDebug(`Was not able to fetch resource ${r[1]}. Error: ${e}`);
|
||||||
// here we are adding undefined values, that will be removed later.
|
// here we are adding undefined values, that will be removed later.
|
||||||
return undefined;
|
return undefined;
|
||||||
})
|
});
|
||||||
)
|
});
|
||||||
];
|
|
||||||
|
|
||||||
// forwarding model files list, remote files list and remote buffers.
|
// forwarding model files list, remote files list and remote buffers.
|
||||||
return [
|
return [
|
||||||
|
|||||||
Reference in New Issue
Block a user