mirror of https://github.com/CesiumGS/obj2gltf.git
Fix unhandled error when obj or mtl is missing
This commit is contained in:
parent
3f8d2e6af7
commit
a62de758dc
|
@ -2,6 +2,7 @@
|
||||||
const fsExtra = require("fs-extra");
|
const fsExtra = require("fs-extra");
|
||||||
const Promise = require("bluebird");
|
const Promise = require("bluebird");
|
||||||
const readline = require("readline");
|
const readline = require("readline");
|
||||||
|
const events = require("events");
|
||||||
|
|
||||||
module.exports = readLines;
|
module.exports = readLines;
|
||||||
|
|
||||||
|
@ -15,8 +16,9 @@ module.exports = readLines;
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function readLines(path, callback) {
|
function readLines(path, callback) {
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
const stream = fsExtra.createReadStream(path);
|
const stream = fsExtra.createReadStream(path);
|
||||||
|
return events.once(stream, "open").then(function () {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
stream.on("error", reject);
|
stream.on("error", reject);
|
||||||
stream.on("end", resolve);
|
stream.on("end", resolve);
|
||||||
|
|
||||||
|
@ -34,4 +36,5 @@ function readLines(path, callback) {
|
||||||
|
|
||||||
lineReader.on("line", callbackWrapper);
|
lineReader.on("line", callbackWrapper);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue