Skip to content

Commit

Permalink
refactor: move from --unstable-hmr to --hmr
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Apr 20, 2024
1 parent a3a5e1e commit 40a85f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
10 changes: 5 additions & 5 deletions commands/serve.ts
Expand Up @@ -30,7 +30,7 @@ export default class Serve extends BaseCommand {
'',
'You can also start the server with HMR support using the following command.',
'```',
'{{ binaryName }} serve --unstable-hmr',
'{{ binaryName }} serve --hmr',
'```',
'',
'The assets bundler dev server runs automatically after detecting vite config or webpack config files',
Expand All @@ -47,7 +47,7 @@ export default class Serve extends BaseCommand {
declare devServer: DevServer

@flags.boolean({ description: 'Start the server with HMR support' })
declare unstableHmr?: boolean
declare hmr?: boolean

@flags.boolean({
description: 'Watch filesystem and restart the HTTP server on file change',
Expand Down Expand Up @@ -120,14 +120,14 @@ export default class Serve extends BaseCommand {
return
}

if (this.watch && this.unstableHmr) {
this.logger.error('Cannot use --watch and --unstable-hmr flags together. Choose one of them')
if (this.watch && this.hmr) {
this.logger.error('Cannot use --watch and --hmr flags together. Choose one of them')
this.exitCode = 1
return
}

this.devServer = new assembler.DevServer(this.app.appRoot, {
hmr: this.unstableHmr === true ? true : false,
hmr: this.hmr === true ? true : false,
clearScreen: this.clear === false ? false : true,
nodeArgs: this.parsed.nodeArgs,
scriptArgs: [],
Expand Down
9 changes: 3 additions & 6 deletions tests/commands/serve.spec.ts
Expand Up @@ -338,7 +338,7 @@ test.group('Serve command', () => {
await sleep(1200)
})

test('error if --unstable-hmr and --watch are used together', async ({ assert, fs }) => {
test('error if --hmr and --watch are used together', async ({ assert, fs }) => {
await fs.create('node_modules/ts-node/esm.js', '')

const ace = await new AceFactory().make(fs.baseUrl, {
Expand All @@ -347,15 +347,12 @@ test.group('Serve command', () => {

ace.ui.switchMode('raw')

const command = await ace.create(Serve, ['--unstable-hmr', '--watch', '--no-clear'])
const command = await ace.create(Serve, ['--hmr', '--watch', '--no-clear'])
await command.exec()

assert.equal(command.exitCode, 1)
assert.lengthOf(ace.ui.logger.getLogs(), 1)
assert.equal(ace.ui.logger.getLogs()[0].stream, 'stderr')
assert.match(
ace.ui.logger.getLogs()[0].message,
/Cannot use --watch and --unstable-hmr flags together/
)
assert.match(ace.ui.logger.getLogs()[0].message, /Cannot use --watch and --hmr flags together/)
})
})

0 comments on commit 40a85f9

Please sign in to comment.