wireit
Version:
Upgrade your npm scripts to make them smarter and more efficient
82 lines • 2.72 kB
JavaScript
/**
* @license
* Copyright 2023 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
// To prevent using the global console accidentally, we shadow it with
// undefined
const console = undefined;
function markAsUsed(_) { }
markAsUsed(console);
/**
* A logger for watch mode that avoids useless output.
*/
export class WatchLogger {
/* The first iteration is always interesting. */ true;
constructor(actualLogger) {
this.
this.console = actualLogger.console;
}
log(event) {
if (this.
// This iteration previously had an interesting event (or it's the very
// first one, which we always show).
this.
this.
if (this.
this.
}
}
else if (this.
// We finished a watch iteration and nothing interesting ever happened.
// Discard the buffer.
this.
}
else if (this.
// The first interesting event of the iteration. Flush the buffer and log
// everything from now until the next iteration.
while (this.
this.
}
this.
this.
}
else {
// An uninteresting event in a thus far uninteresting iteration.
this.
}
}
printMetrics() {
// printMetrics() not used in watch-logger.
}
const code = event.type === 'output'
? event.stream
: event.type === 'info'
? event.detail
: event.reason;
switch (code) {
case 'fresh':
case 'no-command':
case 'failed-previous-watch-iteration':
case 'watch-run-start':
case 'start-cancelled':
case 'locked':
case 'analysis-completed': {
return false;
}
}
return true;
}
return event.type === 'info' && event.detail === 'watch-run-end';
}
[]() {
this.
this.console[Symbol.dispose]();
}
}
//# sourceMappingURL=watch-logger.js.map