Make all native image functions synchronous
This commit is contained in:
parent
f44abc5576
commit
6cecd4b9d6
39 changed files with 1581 additions and 1996 deletions
|
@ -15,14 +15,16 @@ exports.run = object => {
|
|||
// If no image type is given (say, the command generates its own image), make it a PNG.
|
||||
const fileExtension = object.type ? object.type.split("/")[1] : "png";
|
||||
const objectWithFixedType = Object.assign({}, object, {type: fileExtension});
|
||||
magick[object.cmd](objectWithFixedType, (error, data, type) => {
|
||||
if (error) reject(error);
|
||||
try {
|
||||
const result = magick[object.cmd](objectWithFixedType);
|
||||
const returnObject = {
|
||||
buffer: data,
|
||||
fileExtension: type
|
||||
buffer: result.data,
|
||||
fileExtension: result.type
|
||||
};
|
||||
resolve(returnObject);
|
||||
});
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ exports.disconnect = async () => {
|
|||
connection.destroy();
|
||||
}
|
||||
for (const uuid of Object.keys(jobs)) {
|
||||
jobs[uuid].emit("error", new Error("Job ended prematurely (not really an error; just run your image job again)"));
|
||||
jobs[uuid].emit("error", "Job ended prematurely (not really an error; just run your image job again)");
|
||||
}
|
||||
this.connections = [];
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue