Skip to content

Commit

Permalink
Fix output file bugs (#210)
Browse files Browse the repository at this point in the history
* Fix output option bugs

* If output file is .tsx, set options.types to true
  • Loading branch information
willkrakow committed Dec 21, 2023
1 parent 86594d3 commit fed85b7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/gltfjsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,21 @@ export default function (file, output, options) {
}

return new Promise((resolve, reject) => {
const stream = fs.createWriteStream(output)
const stream = fs.createWriteStream(path.resolve(output))
stream.once('open', async (fd) => {
if (!fs.existsSync(file)) {
reject(file + ' does not exist.')
} else {
let size = ''
// Process GLTF
if (output && path.parse(output).ext === '.tsx') {
options.types = true
}

if (options.transform || options.instance || options.instanceall) {
const { name } = path.parse(file)
const transformOut = path.join(name + '-transformed.glb')
const outputDir = path.parse(path.resolve(output ?? file)).dir;
const transformOut = path.join(outputDir, name + '-transformed.glb')
await transform(file, transformOut, options)
const { size: sizeOriginal, sizeKB: sizeKBOriginal } = getFileSize(file)
const { size: sizeTransformed, sizeKB: sizeKBTransformed } = getFileSize(transformOut)
Expand Down

0 comments on commit fed85b7

Please sign in to comment.