RoadmapShopEvents
Skip to main content

Home > @rushstack/terminal > StderrLineTransform

StderrLineTransform class

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

StderrLineTransform normalizes lines that mix characters from stdout and stderr, so that each output line is routed entirely to stdout or stderr.

Signature:

export declare class StderrLineTransform extends TerminalTransform 

Extends: TerminalTransform

Remarks

IMPORTANT: This transform assumes that its input has been normalized to use "\n" newlines.

IMPORTANT: This transform does not produce realtime output, because lines are buffered until a newline character is encountered.

Suppose that a poorly behaved process produces output like this:

process.stderr.write('An error occurred, cleaning up');
process.stdout.write('.'); // (delay)
process.stdout.write('.'); // (delay)
process.stdout.write('.');
process.stdout.write('\n');
process.stderr.write('The process completed with errors\n');

When stdout and stderr are combined on the console, the mistake in the output would not be noticeable:

An error occurred, cleaning up...
The process completed with errors

However, if we discard stdout, then stderr is malformed:

An error occurred, cleaning upThe process completed with errors

Tooling scripts can introduce these sorts of problems via edge cases that are difficult to find and fix.

StderrLineTransform normalizes the output so that if a combined line contains any stderr characters, then the entire line is routed to stderr. Later, if we discard stdout, then the output will preserve the appropriate context:

An error occurred, cleaning up...
The process completed with errors

Constructors

ConstructorModifiersDescription
(constructor)(options)(BETA) Constructs a new instance of the StderrLineTransform class

Properties

PropertyModifiersTypeDescription
destinationreadonlyTerminalWritable

The target TerminalWritable that the TerminalTransform will write its output to.

(Inherited from TerminalTransform)

isOpenreadonlyboolean

This property is initially true when the object is constructed, and becomes false when close() is called.

(Inherited from TerminalWritable)

newlinereadonlystring(BETA)
preventAutoclosereadonlyboolean(Inherited from TerminalWritable)
preventDestinationAutoclosereadonlyboolean

Prevents the TerminalTransform.destination object from being closed automatically when the transform is closed.

(Inherited from TerminalTransform)

Methods

MethodModifiersDescription
autocloseDestination()protected

The default implementation of TerminalTransform.onClose() calls this method, which closes the TerminalTransform.destination if appropriate.

(Inherited from TerminalTransform)

close()

Calling this method flushes any remaining outputs and permanently transitions the TerminalWritable to a "closed" state, where no further chunks can be written.

(Inherited from TerminalWritable)

onClose()protected(BETA)
onWriteChunk(chunk)protected(BETA)
writeChunk(chunk)

Upstream objects call this method to provide inputs to this object.

(Inherited from TerminalWritable)