Skip to content

Commit

Permalink
Merge pull request #146 from xeokit/fix-extension-detection
Browse files Browse the repository at this point in the history
Fix source file extension detection
  • Loading branch information
xeolabs authored Apr 18, 2024
2 parents b77a079 + d051b8e commit 35a5cd7
Show file tree
Hide file tree
Showing 10 changed files with 17,086 additions and 14,480 deletions.
10 changes: 9 additions & 1 deletion convert2xkt.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ function log(msg) {
}
}

function getFileExtension(fileName) {
let ext = path.extname(source);
if (ext.charAt(0) === ".") {
ext = ext.substring(1);
}
return ext;
}

async function main() {

log(`[convert2xkt] Running convert2xkt v${npmPackage.version}...`);
Expand Down Expand Up @@ -148,7 +156,7 @@ async function main() {
const metaModelSource = (i < manifest.metadataOutFiles.length) ? manifest.metadataOutFiles[i] : null;
const outputFileName = getFileNameWithoutExtension(source);
const outputFileNameXKT = `${outputFileName}.xkt`;
const ext = path.extname(source);
const ext = getFileExtension(source);

let modelAABB;
// if (manifest.modelBoundsMin && manifest.modelBoundsMax) {
Expand Down
13 changes: 12 additions & 1 deletion dist/convert2xkt.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26767,6 +26767,14 @@ function convert2xkt({
stats.conversionTime = 0;
stats.aabb = null;

function getFileExtension(fileName) {
let ext = path.extname(source);
if (ext.charAt(0) === ".") {
ext = ext.substring(1);
}
return ext;
}

return new Promise(function (resolve, reject) {
const _log = log;
log = (msg) => {
Expand Down Expand Up @@ -26795,7 +26803,10 @@ function convert2xkt({
const startTime = new Date();

const sourceConfigs = configs.sourceConfigs || {};
const ext = sourceFormat || path.extname(source);
const ext = sourceFormat || getFileExtension();

log(`Input file extension: "${ext}"`);

let fileTypeConfigs = sourceConfigs[ext];

if (!fileTypeConfigs) {
Expand Down
2 changes: 1 addition & 1 deletion dist/xeokit-convert.cjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/xeokit-convert.cjs.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 35a5cd7

Please sign in to comment.