Skip to content

Commit

Permalink
Merge branch 'master' into feat/supportV3Validation
Browse files Browse the repository at this point in the history
  • Loading branch information
smoya authored Sep 12, 2023
2 parents 0527ff0 + 27bef88 commit e8137ff
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@asyncapi/cli",
"description": "All in one CLI for all AsyncAPI tools",
"version": "0.54.8",
"version": "0.55.0",
"author": "@asyncapi",
"bin": {
"asyncapi": "./bin/run"
Expand Down
17 changes: 15 additions & 2 deletions src/commands/new/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,21 @@ export default class NewFile extends Command {
async createAsyncapiFile(fileName:string, selectedTemplate:string) {
const asyncApiFile = await readFile(resolve(__dirname, '../../../assets/examples/', selectedTemplate), { encoding: 'utf8' });

const fileNameHasFileExtension = fileName.includes('.');
const fileNameToWriteToDisk = fileNameHasFileExtension ? fileName : `${fileName}.yaml`;
let fileNameToWriteToDisk;

if (!fileName.includes('.')) {
fileNameToWriteToDisk=`${fileName}.yaml`;
} else {
const extension=fileName.split('.')[1];

if (extension==='yml'||extension==='yaml'||extension==='json') {
fileNameToWriteToDisk=fileName;
} else {
console.log('CLI Support only yml, yaml and json extension for file');

return;
}
}

try {
const content = await readFile(fileNameToWriteToDisk, { encoding: 'utf8' });
Expand Down

0 comments on commit e8137ff

Please sign in to comment.