Skip to content

Commit

Permalink
handle initialization errors in CLI (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehrencrona authored Nov 19, 2020
1 parent 4d33924 commit 6b53582
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions packages/kit/src/api/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { DevConfig, Loader } from './types';
import { copy_assets } from '../utils';
import { readFileSync } from 'fs';

export function dev(opts: DevConfig) {
return new Watcher(opts);
export function dev(opts: DevConfig): Promise<Watcher> {
return new Watcher(opts).init();
}

class Watcher extends EventEmitter {
Expand All @@ -47,8 +47,6 @@ class Watcher extends EventEmitter {
process.on('exit', () => {
this.close();
});

this.init();
}

async init() {
Expand All @@ -61,6 +59,8 @@ class Watcher extends EventEmitter {
this.emit('ready', {
port: this.opts.port
} as ReadyEvent);

return this;
}

async init_filewatcher() {
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ prog.command('dev')
const { dev } = await import('./api/dev');

try {
const watcher = dev({
const watcher = await dev({
port: opts.port
});

Expand Down

0 comments on commit 6b53582

Please sign in to comment.