don't execute the callback inside of a try-catch as if the callback errors then it'll emit the error back to the callback
This commit is contained in:
parent
52202543ff
commit
de45daaef8
@ -34,17 +34,21 @@ export function transformFile(filename: string, opts?: Object, callback: Functio
|
|||||||
opts.filename = filename;
|
opts.filename = filename;
|
||||||
|
|
||||||
fs.readFile(filename, function (err, code) {
|
fs.readFile(filename, function (err, code) {
|
||||||
if (err) return callback(err);
|
|
||||||
|
|
||||||
let result;
|
let result;
|
||||||
|
|
||||||
try {
|
if (!err) {
|
||||||
result = transform(code, opts);
|
try {
|
||||||
} catch (err) {
|
result = transform(code, opts);
|
||||||
return callback(err);
|
} catch (_err) {
|
||||||
|
err = _err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, result);
|
if (err) {
|
||||||
|
callback(err);
|
||||||
|
} else {
|
||||||
|
callback(null, result);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user