mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 11:15:14 +00:00
print file/location/frame when encountering an initial error in dev
This commit is contained in:
@@ -199,9 +199,10 @@ class Watcher extends EventEmitter {
|
||||
});
|
||||
|
||||
manifest_data = new_manifest_data;
|
||||
} catch (err) {
|
||||
} catch (error) {
|
||||
this.emit('error', <ErrorEvent>{
|
||||
message: err.message
|
||||
type: 'manifest',
|
||||
error
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -408,11 +409,11 @@ class Watcher extends EventEmitter {
|
||||
}) {
|
||||
compiler.oninvalid(invalid);
|
||||
|
||||
compiler.watch((err?: Error, result?: CompileResult) => {
|
||||
if (err) {
|
||||
compiler.watch((error?: Error, result?: CompileResult) => {
|
||||
if (error) {
|
||||
this.emit('error', <ErrorEvent>{
|
||||
type: name,
|
||||
message: err.message
|
||||
error
|
||||
});
|
||||
} else {
|
||||
this.emit('build', {
|
||||
|
||||
13
src/cli.ts
13
src/cli.ts
@@ -89,8 +89,17 @@ prog.command('dev')
|
||||
});
|
||||
|
||||
watcher.on('error', (event: ErrorEvent) => {
|
||||
console.log(colors.red(`✗ ${event.type}`));
|
||||
console.log(colors.red(event.message));
|
||||
const { type, error } = event;
|
||||
|
||||
console.log(colors.bold().red(`✗ ${type}`));
|
||||
|
||||
if (error.loc) {
|
||||
let file = error.loc.file && `${path.relative(process.cwd(), error.loc.file)} (${error.loc.line}:${error.loc.column})`;
|
||||
if (file) console.log(colors.bold(file));
|
||||
}
|
||||
|
||||
console.log(colors.red(event.error.message));
|
||||
if (error.frame) console.log(error.frame);
|
||||
});
|
||||
|
||||
watcher.on('fatal', (event: FatalEvent) => {
|
||||
|
||||
@@ -69,7 +69,7 @@ export type ReadyEvent = {
|
||||
|
||||
export type ErrorEvent = {
|
||||
type: string;
|
||||
message: string;
|
||||
error: Error;
|
||||
};
|
||||
|
||||
export type FatalEvent = {
|
||||
|
||||
Reference in New Issue
Block a user