From aadce2daf240dca3ab4e48c9030c46ca12f931d7 Mon Sep 17 00:00:00 2001 From: Adi-204 Date: Tue, 21 Jan 2025 17:44:54 +0530 Subject: [PATCH] fix: lint error --- src/commands/start/studio.ts | 4 ++-- src/core/models/Studio.ts | 34 ++++++++++++++++------------------ 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/commands/start/studio.ts b/src/commands/start/studio.ts index f891046d273..69e206c3bbd 100644 --- a/src/commands/start/studio.ts +++ b/src/commands/start/studio.ts @@ -22,14 +22,14 @@ export default class StartStudio extends Command { filePath = ((await load()).getFilePath()); this.log(`Loaded specification from: ${filePath}`); } catch (error) { - filePath = ""; + filePath = ''; this.log('No file specified.'); } } try { this.specFile = await load(filePath); } catch (error) { - if(filePath){ + if (filePath) { this.error(error as Error); } } diff --git a/src/core/models/Studio.ts b/src/core/models/Studio.ts index ca11e13638b..69b08171686 100644 --- a/src/core/models/Studio.ts +++ b/src/core/models/Studio.ts @@ -27,23 +27,23 @@ export function start(filePath: string, port: number = DEFAULT_PORT): void { if (filePath) { chokidar.watch(filePath).on('all', (event, path) => { switch (event) { - case 'add': - case 'change': - getFileContent(path).then((code: string) => { - messageQueue.push(JSON.stringify({ - type: 'file:changed', - code, - })); - sendQueuedMessages(); - }); - break; - case 'unlink': + case 'add': + case 'change': + getFileContent(path).then((code: string) => { messageQueue.push(JSON.stringify({ - type: 'file:deleted', - filePath, + type: 'file:changed', + code, })); sendQueuedMessages(); - break; + }); + break; + case 'unlink': + messageQueue.push(JSON.stringify({ + type: 'file:deleted', + filePath, + })); + sendQueuedMessages(); + break; } }); } @@ -81,8 +81,7 @@ export function start(filePath: string, port: number = DEFAULT_PORT): void { })); sendQueuedMessages(); }); - } - else{ + } else { messageQueue.push(JSON.stringify({ type: 'file:loaded', code: '', @@ -115,8 +114,7 @@ export function start(filePath: string, port: number = DEFAULT_PORT): void { console.log(`You can open this URL in your web browser, and if needed, press ${gray('Ctrl + C')} to stop the process.`); if (filePath) { console.log(`Watching changes on file ${filePath}`); - } - else{ + } else { console.log( 'Hint : No file was provided, and we couldn\'t find a default file (like "asyncapi.yaml" or "asyncapi.json") in the current folder. Starting Studio with a blank workspace.' );