Skip to content

Commit

Permalink
feat: add node ace serve command
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Aug 21, 2022
1 parent 4c1a09a commit db7242e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions src/commands/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`

Expand Down Expand Up @@ -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',
Expand Down
23 changes: 23 additions & 0 deletions src/commands/serve/index.ts
Original file line number Diff line number Diff line change
@@ -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,
})
}
}

0 comments on commit db7242e

Please sign in to comment.