RoadmapShopEvents
Skip to main content

Home > @rushstack/terminal > DiscardStdoutTransform

DiscardStdoutTransform 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.

DiscardStdoutTransform discards stdout chunks while fixing up malformed stderr lines.

Signature:

export declare class DiscardStdoutTransform extends TerminalTransform 

Extends: TerminalTransform

Remarks

Suppose that a poorly behaved process produces output like this:

process.stdout.write('Starting operation...\n');
process.stderr.write('An error occurred');
process.stdout.write('\nFinishing up\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:

Starting operation...
An error occurred
Finishing up
The process completed with errors

However, if we discard stdout, then stderr is missing a newline:

An error occurredThe process completed with errors

Tooling scripts can introduce these sorts of problems via edge cases that are difficult to find and fix. DiscardStdoutTransform can discard the stdout stream and fix up stderr:

An error occurred
The process completed with errors

Constructors

ConstructorModifiersDescription
(constructor)(options)(BETA) Constructs a new instance of the DiscardStdoutTransform 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)

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

(Inherited from TerminalTransform)

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

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

(Inherited from TerminalWritable)