diff --git a/package.json b/package.json index 71a0f8e..aa8a74c 100644 --- a/package.json +++ b/package.json @@ -420,6 +420,10 @@ "command": "adonis-vscode-extension.type-check", "title": "⌨️ AdonisJS(Ace) Type Check" }, + { + "command": "adonis-vscode-extension.serve", + "title": "⌨️ AdonisJS(Ace) Serve" + }, { "command": "adonis-vscode-extension.list.routes", "title": "⌨️ AdonisJS(Ace) List Routes" diff --git a/src/commands/commands.ts b/src/commands/commands.ts index a5b4c50..59f8dc7 100644 --- a/src/commands/commands.ts +++ b/src/commands/commands.ts @@ -23,6 +23,7 @@ import { Rollback } from './migration/rollback' import { Suite } from './make/suite' import { Factory } from './make/factory' import { Policy } from './make/policy' +import { Serve } from './serve' const buildIdentifier = (identifier: string) => `${EXTENSION_NAME}.${identifier}` @@ -160,6 +161,13 @@ export const commands = [ icon: 'symbol-misc', description: 'Miscellaneous commands', children: [ + { + aceCommand: 'serve', + description: + 'Start the AdonisJS HTTP server, along with the file watcher. Also starts the webpack dev server when webpack encore is installed', + commandIdentifier: buildIdentifier(`serve`), + handler: () => Serve.run(), + }, { aceCommand: 'generate:manifest', description: 'Generate ace commands manifest file. Manifest file speeds up commands lookup', diff --git a/src/commands/serve/index.ts b/src/commands/serve/index.ts new file mode 100644 index 0000000..169c253 --- /dev/null +++ b/src/commands/serve/index.ts @@ -0,0 +1,23 @@ +import BaseCommand from '../base_command' + +/** + * Handle node ace serve command + */ +export class Serve extends BaseCommand { + public static async run() { + /** + * Should watch the files ? + */ + const watchMode = await this.getYesNo('Should run in watch mode ?') + + /** + * Execute the command + */ + return this.handleExecCmd({ + command: `serve ${watchMode ? '-w' : ''}`, + successMessage: '', + errorMessage: 'Could not run dev server.', + background: false, + }) + } +}