Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/action/actions/editor.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ export class EditorAction extends AbstractAction {
public async handle(args: Input, options: Input): Promise<HandleResult> {
const directory = getDirectoryInput(options);
const path = getPathInput(args);
const open = getEditorOpenInput(options, !!path);
const shouldOpen = getEditorOpenInput(options, !!path);
const query = path ? `?projectPath=${encodeURIComponent(path)}` : "";
const url = `http://localhost:3000/load-project${query}`;

console.log(`\n🔗 Editor running! Open it in your browser: \x1b[36m${url}\x1b[0m\n`);

void this.startEditor(directory);
if (open) await this.openEditor(path);
if (shouldOpen) await this.openBrowser(url);

return { keepAlive: true };
}
Expand All @@ -39,9 +43,7 @@ export class EditorAction extends AbstractAction {
});
}

private async openEditor(path: string | undefined): Promise<void> {
const query = path ? `?projectPath=${encodeURIComponent(path)}` : "";
const url = `http://localhost:3000/load-project${query}`;
private async openBrowser(url: string): Promise<void> {
await open(url);
}
}
Loading