mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-19 22:05:20 +00:00
dont buffer stdout/stderr
This commit is contained in:
@@ -214,12 +214,9 @@ class Watcher extends EventEmitter {
|
|||||||
// TODO watch the configs themselves?
|
// TODO watch the configs themselves?
|
||||||
const compilers: Compilers = await create_compilers(this.bundler, cwd, src, dest, false);
|
const compilers: Compilers = await create_compilers(this.bundler, cwd, src, dest, false);
|
||||||
|
|
||||||
let log = '';
|
|
||||||
|
|
||||||
const emitFatal = () => {
|
const emitFatal = () => {
|
||||||
this.emit('fatal', <FatalEvent>{
|
this.emit('fatal', <FatalEvent>{
|
||||||
message: `Server crashed`,
|
message: `Server crashed`
|
||||||
log
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.crashed = true;
|
this.crashed = true;
|
||||||
@@ -236,7 +233,6 @@ class Watcher extends EventEmitter {
|
|||||||
handle_result: (result: CompileResult) => {
|
handle_result: (result: CompileResult) => {
|
||||||
deferred.promise.then(() => {
|
deferred.promise.then(() => {
|
||||||
const restart = () => {
|
const restart = () => {
|
||||||
log = '';
|
|
||||||
this.crashed = false;
|
this.crashed = false;
|
||||||
|
|
||||||
ports.wait(this.port)
|
ports.wait(this.port)
|
||||||
@@ -260,8 +256,7 @@ class Watcher extends EventEmitter {
|
|||||||
if (this.crashed) return;
|
if (this.crashed) return;
|
||||||
|
|
||||||
this.emit('fatal', <FatalEvent>{
|
this.emit('fatal', <FatalEvent>{
|
||||||
message: `Server is not listening on port ${this.port}`,
|
message: `Server is not listening on port ${this.port}`
|
||||||
log
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -292,12 +287,10 @@ class Watcher extends EventEmitter {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.proc.stdout.on('data', chunk => {
|
this.proc.stdout.on('data', chunk => {
|
||||||
log += chunk;
|
|
||||||
this.emit('stdout', chunk);
|
this.emit('stdout', chunk);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.proc.stderr.on('data', chunk => {
|
this.proc.stderr.on('data', chunk => {
|
||||||
log += chunk;
|
|
||||||
this.emit('stderr', chunk);
|
this.emit('stderr', chunk);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
18
src/cli.ts
18
src/cli.ts
@@ -64,6 +64,14 @@ prog.command('dev')
|
|||||||
|
|
||||||
let first = true;
|
let first = true;
|
||||||
|
|
||||||
|
watcher.on('stdout', data => {
|
||||||
|
process.stdout.write(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
watcher.on('stderr', data => {
|
||||||
|
process.stderr.write(data);
|
||||||
|
});
|
||||||
|
|
||||||
watcher.on('ready', async (event: ReadyEvent) => {
|
watcher.on('ready', async (event: ReadyEvent) => {
|
||||||
if (first) {
|
if (first) {
|
||||||
console.log(colors.bold.cyan(`> Listening on http://localhost:${event.port}`));
|
console.log(colors.bold.cyan(`> Listening on http://localhost:${event.port}`));
|
||||||
@@ -73,16 +81,6 @@ prog.command('dev')
|
|||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO clear screen?
|
|
||||||
|
|
||||||
event.process.stdout.on('data', data => {
|
|
||||||
process.stdout.write(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
event.process.stderr.on('data', data => {
|
|
||||||
process.stderr.write(data);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
watcher.on('invalid', (event: InvalidEvent) => {
|
watcher.on('invalid', (event: InvalidEvent) => {
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ export type ErrorEvent = {
|
|||||||
|
|
||||||
export type FatalEvent = {
|
export type FatalEvent = {
|
||||||
message: string;
|
message: string;
|
||||||
log?: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type InvalidEvent = {
|
export type InvalidEvent = {
|
||||||
|
|||||||
Reference in New Issue
Block a user