From 3a538132b73be3a2322d6c44c9791e0918580fe7 Mon Sep 17 00:00:00 2001 From: bedi gupta Date: Thu, 10 Oct 2024 15:35:53 +0530 Subject: [PATCH] remove cli.js file --- apps/generator/cli.js | 58 +++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/apps/generator/cli.js b/apps/generator/cli.js index 66aef7109..0fd464b10 100755 --- a/apps/generator/cli.js +++ b/apps/generator/cli.js @@ -141,41 +141,29 @@ xfs.mkdirp(program.output, async err => { * @param {*} targetDir The path to the target directory. */ function generate(targetDir) { - return new Promise((resolve, reject) => { - (async () => { - try { - const generator = new Generator( - template, - targetDir || path.resolve(os.tmpdir(), "asyncapi-generator"), - { - templateParams: params, - noOverwriteGlobs, - disabledHooks, - forceWrite: program.forceWrite, - install: program.install, - debug: program.debug, - mapBaseUrlToFolder, - } - ); - - if (isAsyncapiDocLocal) { - await generator.generateFromFile(path.resolve(asyncapiDocPath)); - } else { - await generator.generateFromURL(asyncapiDocPath); - } - console.log(green("\n\nDone! ✨")); - console.log( - `${ - yellow("Check out your shiny new generated files at ") + - magenta(program.output) + - yellow(".") - }\n` - ); - resolve(); - } catch (e) { - reject(e); + return new Promise(async (resolve, reject) => { + try { + const generator = new Generator(template, targetDir || path.resolve(os.tmpdir(), 'asyncapi-generator'), { + templateParams: params, + noOverwriteGlobs, + disabledHooks, + forceWrite: program.forceWrite, + install: program.install, + debug: program.debug, + mapBaseUrlToFolder + }); + + if (isAsyncapiDocLocal) { + await generator.generateFromFile(path.resolve(asyncapiDocPath)); + } else { + await generator.generateFromURL(asyncapiDocPath); } - })(); //Immediately invoke the async function + console.log(green('\n\nDone! ✨')); + console.log(`${yellow('Check out your shiny new generated files at ') + magenta(program.output) + yellow('.')}\n`); + resolve(); + } catch (e) { + reject(e); + } }); } @@ -207,4 +195,4 @@ async function watcherHandler(changedFiles) { } } -process.on('unhandledRejection', showErrorAndExit); +process.on('unhandledRejection', showErrorAndExit); \ No newline at end of file