Skip to content

Commit

Permalink
fix lint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
aayushRedHat committed Sep 12, 2023
1 parent 93bea8e commit 5c0daaf
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions src/commands/new/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,33 +136,23 @@ export default class NewFile extends Command {
}

async createAsyncapiFile(fileName:string, selectedTemplate:string) {

const asyncApiFile = await readFile(resolve(__dirname, '../../../assets/examples/', selectedTemplate), { encoding: 'utf8' });


let fileNameToWriteToDisk;

if(!fileName.includes(".")){

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

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 ;
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 5c0daaf

Please sign in to comment.