Skip to content

Commit 3bc711b

Browse files
committed
fix: allow relative config name and explicit extension, refs #131
1 parent 0dec7dc commit 3bc711b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cg.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,14 @@ let configStr = argv._[0] || 'nodejs';
6666
let configName = path.basename(configStr);
6767
let remoteConfig = configName.indexOf(':')>-1;
6868
let configPath = path.dirname(configStr);
69-
if (!configPath || (configPath === '.')) configPath = path.resolve(__dirname,'configs');
70-
let configFile = path.join(configPath,configName)+'.json';
69+
if (!configPath) configPath = path.resolve(__dirname,'configs');
70+
let configFile = path.join(configPath,configName);
71+
if (!path.extname(configFile)) {
72+
configFile += '.json';
73+
}
74+
else {
75+
configName = configName.replace(path.extname(configFile),'');
76+
}
7177
let config = remoteConfig ? { defaults: {} } : yaml.parse(fs.readFileSync(configFile,'utf8'), {prettyErrors: true});
7278
let defName = argv._[1] || path.resolve(__dirname,'defs/petstore3.json');
7379

0 commit comments

Comments
 (0)