• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

papandreou / impro / 7222145580

15 Dec 2023 12:03PM UTC coverage: 92.561% (-1.0%) from 93.572%
7222145580

push

github

alexjeffburke
Introduce StdinoutStream.

This commit adds an implementation of a transform stream intended to
abstract spawning a command line utility which receives data on stdin
and outputs a result on stdout. Any data written to the stream (i.e.
pipe()'ing a Readable stream to it or otherwise) is sent onwards to
the child process and any data it produces it available to be read
downstream. To the extent possible this is fully streamed and care
has been taken to handle various error conditions and non-determistic
execution ordering e.g. child process stdout versus its exit event.

The genesis for doing this came from looking into a report of an
uncaught exception related to the use of gifsicle. A code inspection
combined with having a fair share of "experences" with streams left
a somewhat uneasy feeling and, given that some better facilities are
available in newer node together (e.g. Transform streams) and with
an awareness behaviours have been subtlely tweaked, lead to concluding
it worthwhile to invest in using a new hardened wrapper going forward.
This culmination of that work built out using gifsicle as the target.

This is intended for potentially sharing across tools going forward.

604 of 743 branches covered (0.0%)

114 of 132 new or added lines in 3 files covered. (86.36%)

9 existing lines in 1 file now uncovered.

871 of 941 relevant lines covered (92.56%)

35.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.25
/src/debug.js
1
const IS_DEBUG = /^(?:1|true|on|yes)$/i.test(process.env.DEBUG);
1✔
2

3
function noop() {}
4

5
class DebugLogger {
6
  constructor(namespace, _log) {
7
    this.namespace = namespace;
6✔
8
    this.log = _log || noop;
6✔
9
  }
10

11
  extend(namespace) {
NEW
12
    const extendedName = [this.name, namespace].join(':');
×
NEW
13
    return new DebugLogger(extendedName);
×
14
  }
15

16
  format(msg) {
17
    return `${this.namespace}: ${msg}`;
9✔
18
  }
19

20
  static createLogger(namespace) {
21
    const _log = IS_DEBUG && console.warn;
6!
22
    const debugLogger = new DebugLogger(namespace, _log);
6✔
23
    const logger = (msg) => debugLogger.log(debugLogger.format(msg));
9✔
24
    logger.extend = (namespace) => debugLogger.extend(namespace);
6✔
25
    Object.defineProperty(logger, 'enabled', {
6✔
NEW
26
      get: () => IS_DEBUG,
×
27
    });
28
    Object.defineProperty(logger, 'namespace', {
6✔
29
      get: () => debugLogger.namespace,
4✔
30
    });
31
    return logger;
6✔
32
  }
33
}
34

35
module.exports = DebugLogger.createLogger;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc