mirror of https://github.com/CesiumGS/obj2gltf.git
Use coerce instead
This commit is contained in:
parent
96b8d17009
commit
c5851f49ea
|
@ -23,14 +23,24 @@ var argv = yargs
|
||||||
alias : 'i',
|
alias : 'i',
|
||||||
describe : 'Path to the obj file.',
|
describe : 'Path to the obj file.',
|
||||||
type : 'string',
|
type : 'string',
|
||||||
normalize : true,
|
demandOption : true,
|
||||||
demandOption : true
|
coerce : function (p) {
|
||||||
|
if (p.length === 0) {
|
||||||
|
throw new Error('Input path must be a file name');
|
||||||
|
}
|
||||||
|
return path.resolve(p);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
output : {
|
output : {
|
||||||
alias : 'o',
|
alias : 'o',
|
||||||
describe : 'Path of the converted glTF or glb file.',
|
describe : 'Path of the converted glTF or glb file.',
|
||||||
type : 'string',
|
type : 'string',
|
||||||
normalize : true
|
coerce : function (p) {
|
||||||
|
if (p.length === 0) {
|
||||||
|
throw new Error('Output path must be a file name');
|
||||||
|
}
|
||||||
|
return path.resolve(p);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
binary : {
|
binary : {
|
||||||
alias : 'b',
|
alias : 'b',
|
||||||
|
@ -128,16 +138,6 @@ if (defined(argv.metallicRoughnessOcclusionTexture) && defined(argv.specularGlos
|
||||||
var objPath = argv.input;
|
var objPath = argv.input;
|
||||||
var gltfPath = argv.output;
|
var gltfPath = argv.output;
|
||||||
|
|
||||||
if (objPath === '.') {
|
|
||||||
console.log('Input path is required');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gltfPath === '.') {
|
|
||||||
console.log('Output path must be a filename');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var filename = defaultValue(gltfPath, objPath);
|
var filename = defaultValue(gltfPath, objPath);
|
||||||
var name = path.basename(filename, path.extname(filename));
|
var name = path.basename(filename, path.extname(filename));
|
||||||
var outputDirectory = path.dirname(filename);
|
var outputDirectory = path.dirname(filename);
|
||||||
|
|
Loading…
Reference in New Issue