Merge pull request #268 from CesiumGS/fix-missing-mtl

Fix unhandled error when mtl is missing
This commit is contained in:
Ian Lilley 2021-09-15 12:13:49 -04:00 committed by GitHub
commit 049f7af86b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 16 deletions

View File

@ -1,5 +1,9 @@
# Change Log # Change Log
### 3.1.3 - 2021-09-15
- Fixed bug where missing .mtl files were no longer being handled gracefully in Node 16. [#268](https://github.com/CesiumGS/obj2gltf/pull/268)
### 3.1.2 - 2021-08-02 ### 3.1.2 - 2021-08-02
- Removed `minFilter` and `magFilter` from generated samplers so that runtime engines can use their preferred texture filtering. [#240](https://github.com/CesiumGS/obj2gltf/pull/240) - Removed `minFilter` and `magFilter` from generated samplers so that runtime engines can use their preferred texture filtering. [#240](https://github.com/CesiumGS/obj2gltf/pull/240)

View File

@ -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);
}); });
});
} }