Skip to content

Commit

Permalink
fix: pipe unwanted logs to /dev/null
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanosdev committed Apr 27, 2024
1 parent f1f4c6b commit 543cd9f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/pic/src/pocket-ic-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
isDarwin,
} from './util';
import { StartServerOptions } from './pocket-ic-server-types';
import { Writable } from 'node:stream';

/**
* This class represents the main PocketIC server.
Expand Down Expand Up @@ -74,10 +75,14 @@ export class PocketIcServer {

if (options.showRuntimeLogs) {
serverProcess.stdout.pipe(process.stdout);
} else {
serverProcess.stdout.pipe(new NullStream());
}

if (options.showCanisterLogs) {
serverProcess.stderr.pipe(process.stderr);
} else {
serverProcess.stderr.pipe(new NullStream());
}

serverProcess.on('error', error => {
Expand Down Expand Up @@ -144,3 +149,13 @@ export class PocketIcServer {
chmodSync(binPath, 0o700);
}
}

class NullStream extends Writable {
_write(
_chunk: any,
_encoding: BufferEncoding,
callback: (error?: Error | null) => void,
): void {
callback();
}
}

0 comments on commit 543cd9f

Please sign in to comment.