@rushstack/terminal 0.3.59 → 0.3.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.28.4"
8
+ "packageVersion": "7.28.7"
9
9
  }
10
10
  ]
11
11
  }
@@ -59,14 +59,14 @@ class DiscardStdoutTransform extends TerminalTransform_1.TerminalTransform {
59
59
  if (chunk.text.indexOf('\r') >= 0) {
60
60
  throw new Error('DiscardStdoutTransform expects chunks with normalized newlines');
61
61
  }
62
- if (chunk.kind === "O" /* Stdout */) {
62
+ if (chunk.kind === "O" /* TerminalChunkKind.Stdout */) {
63
63
  if (this._state === State.StderrFragment) {
64
64
  if (chunk.text.indexOf('\n') >= 0) {
65
65
  this._state = State.InsertLinefeed;
66
66
  }
67
67
  }
68
68
  }
69
- else if (chunk.kind === "E" /* Stderr */) {
69
+ else if (chunk.kind === "E" /* TerminalChunkKind.Stderr */) {
70
70
  let correctedText;
71
71
  if (this._state === State.InsertLinefeed) {
72
72
  correctedText = '\n' + chunk.text;
@@ -74,7 +74,7 @@ class DiscardStdoutTransform extends TerminalTransform_1.TerminalTransform {
74
74
  else {
75
75
  correctedText = chunk.text;
76
76
  }
77
- this.destination.writeChunk({ kind: "E" /* Stderr */, text: correctedText });
77
+ this.destination.writeChunk({ kind: "E" /* TerminalChunkKind.Stderr */, text: correctedText });
78
78
  if (correctedText.length > 0) {
79
79
  if (correctedText[correctedText.length - 1] === '\n') {
80
80
  this._state = State.Okay;
@@ -1 +1 @@
1
- {"version":3,"file":"DiscardStdoutTransform.js","sourceRoot":"","sources":["../src/DiscardStdoutTransform.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,2DAAmF;AASnF,IAAK,KAIJ;AAJD,WAAK,KAAK;IACR,iCAAI,CAAA;IACJ,qDAAc,CAAA;IACd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1B;qBAAM;oBACL,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC;iBACpC;aACF;SACF;aAAM;YACL,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;SACpC;IACH,CAAC;CACF;AAzCD,wDAyCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { ITerminalChunk, TerminalChunkKind } from './ITerminalChunk';\nimport { TerminalTransform, ITerminalTransformOptions } from './TerminalTransform';\n\n/**\n * Constructor options for {@link DiscardStdoutTransform}\n *\n * @beta\n */\nexport interface IDiscardStdoutTransformOptions extends ITerminalTransformOptions {}\n\nenum State {\n Okay,\n StderrFragment,\n InsertLinefeed\n}\n\n/**\n * `DiscardStdoutTransform` discards `stdout` chunks while fixing up malformed `stderr` lines.\n *\n * @remarks\n * Suppose that a poorly behaved process produces output like this:\n *\n * ```ts\n * process.stdout.write('Starting operation...\\n');\n * process.stderr.write('An error occurred');\n * process.stdout.write('\\nFinishing up\\n');\n * process.stderr.write('The process completed with errors\\n');\n * ```\n *\n * When `stdout` and `stderr` are combined on the console, the mistake in the output would not be noticeable:\n * ```\n * Starting operation...\n * An error occurred\n * Finishing up\n * The process completed with errors\n * ```\n *\n * However, if we discard `stdout`, then `stderr` is missing a newline:\n * ```\n * An error occurredThe process completed with errors\n * ```\n *\n * Tooling scripts can introduce these sorts of problems via edge cases that are difficult to find and fix.\n * `DiscardStdoutTransform` can discard the `stdout` stream and fix up `stderr`:\n *\n * ```\n * An error occurred\n * The process completed with errors\n * ```\n *\n * @privateRemarks\n * This class is experimental and marked as `@beta`. The algorithm may need some fine-tuning, or there may\n * be better solutions to this problem.\n *\n * @beta\n */\nexport class DiscardStdoutTransform extends TerminalTransform {\n private _state: State;\n\n public constructor(options: IDiscardStdoutTransformOptions) {\n super(options);\n\n this._state = State.Okay;\n }\n\n protected onWriteChunk(chunk: ITerminalChunk): void {\n if (chunk.text.indexOf('\\r') >= 0) {\n throw new Error('DiscardStdoutTransform expects chunks with normalized newlines');\n }\n\n if (chunk.kind === TerminalChunkKind.Stdout) {\n if (this._state === State.StderrFragment) {\n if (chunk.text.indexOf('\\n') >= 0) {\n this._state = State.InsertLinefeed;\n }\n }\n } else if (chunk.kind === TerminalChunkKind.Stderr) {\n let correctedText: string;\n if (this._state === State.InsertLinefeed) {\n correctedText = '\\n' + chunk.text;\n } else {\n correctedText = chunk.text;\n }\n\n this.destination.writeChunk({ kind: TerminalChunkKind.Stderr, text: correctedText });\n\n if (correctedText.length > 0) {\n if (correctedText[correctedText.length - 1] === '\\n') {\n this._state = State.Okay;\n } else {\n this._state = State.StderrFragment;\n }\n }\n } else {\n this.destination.writeChunk(chunk);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"DiscardStdoutTransform.js","sourceRoot":"","sources":["../src/DiscardStdoutTransform.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,2DAAmF;AASnF,IAAK,KAIJ;AAJD,WAAK,KAAK;IACR,iCAAI,CAAA;IACJ,qDAAc,CAAA;IACd,qDAAc,CAAA;AAChB,CAAC,EAJI,KAAK,KAAL,KAAK,QAIT;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAa,sBAAuB,SAAQ,qCAAiB;IAG3D,YAAmB,OAAuC;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC;IAC3B,CAAC;IAES,YAAY,CAAC,KAAqB;QAC1C,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;SACnF;QAED,IAAI,KAAK,CAAC,IAAI,uCAA6B,EAAE;YAC3C,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,cAAc,EAAE;gBACxC,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;oBACjC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC;iBACpC;aACF;SACF;aAAM,IAAI,KAAK,CAAC,IAAI,uCAA6B,EAAE;YAClD,IAAI,aAAqB,CAAC;YAC1B,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,cAAc,EAAE;gBACxC,aAAa,GAAG,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;aACnC;iBAAM;gBACL,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC;aAC5B;YAED,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,IAAI,oCAA0B,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;YAErF,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC5B,IAAI,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE;oBACpD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC;iBAC1B;qBAAM;oBACL,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,cAAc,CAAC;iBACpC;aACF;SACF;aAAM;YACL,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;SACpC;IACH,CAAC;CACF;AAzCD,wDAyCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { ITerminalChunk, TerminalChunkKind } from './ITerminalChunk';\nimport { TerminalTransform, ITerminalTransformOptions } from './TerminalTransform';\n\n/**\n * Constructor options for {@link DiscardStdoutTransform}\n *\n * @beta\n */\nexport interface IDiscardStdoutTransformOptions extends ITerminalTransformOptions {}\n\nenum State {\n Okay,\n StderrFragment,\n InsertLinefeed\n}\n\n/**\n * `DiscardStdoutTransform` discards `stdout` chunks while fixing up malformed `stderr` lines.\n *\n * @remarks\n * Suppose that a poorly behaved process produces output like this:\n *\n * ```ts\n * process.stdout.write('Starting operation...\\n');\n * process.stderr.write('An error occurred');\n * process.stdout.write('\\nFinishing up\\n');\n * process.stderr.write('The process completed with errors\\n');\n * ```\n *\n * When `stdout` and `stderr` are combined on the console, the mistake in the output would not be noticeable:\n * ```\n * Starting operation...\n * An error occurred\n * Finishing up\n * The process completed with errors\n * ```\n *\n * However, if we discard `stdout`, then `stderr` is missing a newline:\n * ```\n * An error occurredThe process completed with errors\n * ```\n *\n * Tooling scripts can introduce these sorts of problems via edge cases that are difficult to find and fix.\n * `DiscardStdoutTransform` can discard the `stdout` stream and fix up `stderr`:\n *\n * ```\n * An error occurred\n * The process completed with errors\n * ```\n *\n * @privateRemarks\n * This class is experimental and marked as `@beta`. The algorithm may need some fine-tuning, or there may\n * be better solutions to this problem.\n *\n * @beta\n */\nexport class DiscardStdoutTransform extends TerminalTransform {\n private _state: State;\n\n public constructor(options: IDiscardStdoutTransformOptions) {\n super(options);\n\n this._state = State.Okay;\n }\n\n protected onWriteChunk(chunk: ITerminalChunk): void {\n if (chunk.text.indexOf('\\r') >= 0) {\n throw new Error('DiscardStdoutTransform expects chunks with normalized newlines');\n }\n\n if (chunk.kind === TerminalChunkKind.Stdout) {\n if (this._state === State.StderrFragment) {\n if (chunk.text.indexOf('\\n') >= 0) {\n this._state = State.InsertLinefeed;\n }\n }\n } else if (chunk.kind === TerminalChunkKind.Stderr) {\n let correctedText: string;\n if (this._state === State.InsertLinefeed) {\n correctedText = '\\n' + chunk.text;\n } else {\n correctedText = chunk.text;\n }\n\n this.destination.writeChunk({ kind: TerminalChunkKind.Stderr, text: correctedText });\n\n if (correctedText.length > 0) {\n if (correctedText[correctedText.length - 1] === '\\n') {\n this._state = State.Okay;\n } else {\n this._state = State.StderrFragment;\n }\n }\n } else {\n this.destination.writeChunk(chunk);\n }\n }\n}\n"]}
@@ -70,7 +70,7 @@ class StderrLineTransform extends TerminalTransform_1.TerminalTransform {
70
70
  const text = chunk.text;
71
71
  let startIndex = 0;
72
72
  while (startIndex < text.length) {
73
- if (chunk.kind === "E" /* Stderr */) {
73
+ if (chunk.kind === "E" /* TerminalChunkKind.Stderr */) {
74
74
  this._accumulatedStderr = true;
75
75
  }
76
76
  const endIndex = text.indexOf('\n', startIndex);
@@ -96,13 +96,13 @@ class StderrLineTransform extends TerminalTransform_1.TerminalTransform {
96
96
  this._accumulatedLine += this.newline;
97
97
  if (this._accumulatedStderr) {
98
98
  this.destination.writeChunk({
99
- kind: "E" /* Stderr */,
99
+ kind: "E" /* TerminalChunkKind.Stderr */,
100
100
  text: this._accumulatedLine
101
101
  });
102
102
  }
103
103
  else {
104
104
  this.destination.writeChunk({
105
- kind: "O" /* Stdout */,
105
+ kind: "O" /* TerminalChunkKind.Stdout */,
106
106
  text: this._accumulatedLine
107
107
  });
108
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"StdioLineTransform.js","sourceRoot":"","sources":["../src/StdioLineTransform.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAiE;AAGjE,2DAAmF;AAanF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,MAAa,mBAAoB,SAAQ,qCAAiB;IAMxD,YAAmB,OAAmC;QACpD,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;QAEhC,IAAI,CAAC,OAAO,GAAG,wBAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,IAAI,+BAAW,CAAC,EAAE,CAAC,CAAC;IACxE,CAAC;IAES,YAAY,CAAC,KAAqB;QAC1C,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CA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aAC5B,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;IAClC,CAAC;CACF;AAxED,kDAwEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Text, NewlineKind } from '@rushstack/node-core-library';\n\nimport { ITerminalChunk, TerminalChunkKind } from './ITerminalChunk';\nimport { TerminalTransform, ITerminalTransformOptions } from './TerminalTransform';\n\n/**\n * Constructor options for {@link StderrLineTransform}\n * @beta\n */\nexport interface IStdioLineTransformOptions extends ITerminalTransformOptions {\n /**\n * Specifies the kind of newline for the output.\n */\n newlineKind?: NewlineKind;\n}\n\n/**\n * `StderrLineTransform` normalizes lines that mix characters from `stdout` and `stderr`,\n * so that each output line is routed entirely to `stdout` or `stderr`.\n *\n * @remarks\n * IMPORTANT: This transform assumes that its input has been normalized to use `\"\\n\"` newlines.\n *\n * IMPORTANT: This transform does not produce realtime output, because lines are buffered\n * until a newline character is encountered.\n *\n * Suppose that a poorly behaved process produces output like this:\n *\n * ```ts\n * process.stderr.write('An error occurred, cleaning up');\n * process.stdout.write('.'); // (delay)\n * process.stdout.write('.'); // (delay)\n * process.stdout.write('.');\n * process.stdout.write('\\n');\n * process.stderr.write('The process completed with errors\\n');\n * ```\n *\n * When `stdout` and `stderr` are combined on the console, the mistake in the output would not be noticeable:\n * ```\n * An error occurred, cleaning up...\n * The process completed with errors\n * ```\n *\n * However, if we discard `stdout`, then `stderr` is malformed:\n * ```\n * An error occurred, cleaning upThe process completed with errors\n * ```\n *\n * Tooling scripts can introduce these sorts of problems via edge cases that are difficult to find and fix.\n *\n * `StderrLineTransform` normalizes the output so that if a combined line contains any `stderr` characters,\n * then the entire line is routed to `stderr`. Later, if we discard `stdout`, then the output will\n * preserve the appropriate context:\n *\n * ```\n * An error occurred, cleaning up...\n * The process completed with errors\n * ```\n *\n * @privateRemarks\n * This class is experimental and marked as `@beta`. The algorithm may need some fine-tuning, or there may\n * be better solutions to this problem.\n *\n * @beta\n */\nexport class StderrLineTransform extends TerminalTransform {\n private _accumulatedLine: string;\n private _accumulatedStderr: boolean;\n\n public readonly newline: string;\n\n public constructor(options: IStdioLineTransformOptions) {\n super(options);\n\n this._accumulatedLine = '';\n this._accumulatedStderr = false;\n\n this.newline = Text.getNewline(options.newlineKind || NewlineKind.Lf);\n }\n\n protected onWriteChunk(chunk: ITerminalChunk): void {\n if (chunk.text.indexOf('\\r') >= 0) {\n throw new Error('StderrLineTransform expects chunks with normalized newlines');\n }\n\n // After _newlineNormalizerTransform was applied, we can now assume that all newlines\n // use the \"\\n\" string\n const text: string = chunk.text;\n let startIndex: number = 0;\n\n while (startIndex < text.length) {\n if (chunk.kind === TerminalChunkKind.Stderr) {\n this._accumulatedStderr = true;\n }\n\n const endIndex: number = text.indexOf('\\n', startIndex);\n if (endIndex < 0) {\n // we did not find \\n, so simply append\n this._accumulatedLine += text.substring(startIndex);\n break;\n }\n\n // append everything up to \\n\n this._accumulatedLine += text.substring(startIndex, endIndex);\n\n this._processAccumulatedLine();\n\n // skip the \\n\n startIndex = endIndex + 1;\n }\n }\n\n protected onClose(): void {\n if (this._accumulatedLine.length > 0) {\n this._processAccumulatedLine();\n }\n this.autocloseDestination();\n }\n\n private _processAccumulatedLine(): void {\n this._accumulatedLine += this.newline;\n\n if (this._accumulatedStderr) {\n this.destination.writeChunk({\n kind: TerminalChunkKind.Stderr,\n text: this._accumulatedLine\n });\n } else {\n this.destination.writeChunk({\n kind: TerminalChunkKind.Stdout,\n text: this._accumulatedLine\n });\n }\n\n this._accumulatedLine = '';\n this._accumulatedStderr = false;\n }\n}\n"]}
1
+ {"version":3,"file":"StdioLineTransform.js","sourceRoot":"","sources":["../src/StdioLineTransform.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAAiE;AAGjE,2DAAmF;AAanF;;;;;;;;;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QACf,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE;YACpC,IAAI,CAAC,uBAAuB,EAAE,CAAC;SAChC;QACD,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAEO,uBAAuB;QAC7B,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,OAAO,CAAC;QAEtC,IAAI,IAAI,CAAC,kBAAkB,EAAE;YAC3B,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC;gBAC1B,IAAI,oCAA0B;gBAC9B,IAAI,EAAE,IAAI,CAAC,gBAAgB;aAC5B,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC;gBAC1B,IAAI,oCAA0B;gBAC9B,IAAI,EAAE,IAAI,CAAC,gBAAgB;aAC5B,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;IAClC,CAAC;CACF;AAxED,kDAwEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { Text, NewlineKind } from '@rushstack/node-core-library';\n\nimport { ITerminalChunk, TerminalChunkKind } from './ITerminalChunk';\nimport { TerminalTransform, ITerminalTransformOptions } from './TerminalTransform';\n\n/**\n * Constructor options for {@link StderrLineTransform}\n * @beta\n */\nexport interface IStdioLineTransformOptions extends ITerminalTransformOptions {\n /**\n * Specifies the kind of newline for the output.\n */\n newlineKind?: NewlineKind;\n}\n\n/**\n * `StderrLineTransform` normalizes lines that mix characters from `stdout` and `stderr`,\n * so that each output line is routed entirely to `stdout` or `stderr`.\n *\n * @remarks\n * IMPORTANT: This transform assumes that its input has been normalized to use `\"\\n\"` newlines.\n *\n * IMPORTANT: This transform does not produce realtime output, because lines are buffered\n * until a newline character is encountered.\n *\n * Suppose that a poorly behaved process produces output like this:\n *\n * ```ts\n * process.stderr.write('An error occurred, cleaning up');\n * process.stdout.write('.'); // (delay)\n * process.stdout.write('.'); // (delay)\n * process.stdout.write('.');\n * process.stdout.write('\\n');\n * process.stderr.write('The process completed with errors\\n');\n * ```\n *\n * When `stdout` and `stderr` are combined on the console, the mistake in the output would not be noticeable:\n * ```\n * An error occurred, cleaning up...\n * The process completed with errors\n * ```\n *\n * However, if we discard `stdout`, then `stderr` is malformed:\n * ```\n * An error occurred, cleaning upThe process completed with errors\n * ```\n *\n * Tooling scripts can introduce these sorts of problems via edge cases that are difficult to find and fix.\n *\n * `StderrLineTransform` normalizes the output so that if a combined line contains any `stderr` characters,\n * then the entire line is routed to `stderr`. Later, if we discard `stdout`, then the output will\n * preserve the appropriate context:\n *\n * ```\n * An error occurred, cleaning up...\n * The process completed with errors\n * ```\n *\n * @privateRemarks\n * This class is experimental and marked as `@beta`. The algorithm may need some fine-tuning, or there may\n * be better solutions to this problem.\n *\n * @beta\n */\nexport class StderrLineTransform extends TerminalTransform {\n private _accumulatedLine: string;\n private _accumulatedStderr: boolean;\n\n public readonly newline: string;\n\n public constructor(options: IStdioLineTransformOptions) {\n super(options);\n\n this._accumulatedLine = '';\n this._accumulatedStderr = false;\n\n this.newline = Text.getNewline(options.newlineKind || NewlineKind.Lf);\n }\n\n protected onWriteChunk(chunk: ITerminalChunk): void {\n if (chunk.text.indexOf('\\r') >= 0) {\n throw new Error('StderrLineTransform expects chunks with normalized newlines');\n }\n\n // After _newlineNormalizerTransform was applied, we can now assume that all newlines\n // use the \"\\n\" string\n const text: string = chunk.text;\n let startIndex: number = 0;\n\n while (startIndex < text.length) {\n if (chunk.kind === TerminalChunkKind.Stderr) {\n this._accumulatedStderr = true;\n }\n\n const endIndex: number = text.indexOf('\\n', startIndex);\n if (endIndex < 0) {\n // we did not find \\n, so simply append\n this._accumulatedLine += text.substring(startIndex);\n break;\n }\n\n // append everything up to \\n\n this._accumulatedLine += text.substring(startIndex, endIndex);\n\n this._processAccumulatedLine();\n\n // skip the \\n\n startIndex = endIndex + 1;\n }\n }\n\n protected onClose(): void {\n if (this._accumulatedLine.length > 0) {\n this._processAccumulatedLine();\n }\n this.autocloseDestination();\n }\n\n private _processAccumulatedLine(): void {\n this._accumulatedLine += this.newline;\n\n if (this._accumulatedStderr) {\n this.destination.writeChunk({\n kind: TerminalChunkKind.Stderr,\n text: this._accumulatedLine\n });\n } else {\n this.destination.writeChunk({\n kind: TerminalChunkKind.Stdout,\n text: this._accumulatedLine\n });\n }\n\n this._accumulatedLine = '';\n this._accumulatedStderr = false;\n }\n}\n"]}
@@ -70,14 +70,14 @@ class StdioSummarizer extends TerminalWritable_1.TerminalWritable {
70
70
  ' Invalid input: ' +
71
71
  JSON.stringify(chunk.text));
72
72
  }
73
- if (chunk.kind === "E" /* Stderr */ && !this._abridgedStderr) {
73
+ if (chunk.kind === "E" /* TerminalChunkKind.Stderr */ && !this._abridgedStderr) {
74
74
  // The first time we see stderr, switch to capturing stderr
75
75
  this._abridgedStderr = true;
76
76
  this._abridgedLeading.length = 0;
77
77
  this._abridgedTrailing.length = 0;
78
78
  this._abridgedOmittedLines = 0;
79
79
  }
80
- else if (this._abridgedStderr && chunk.kind !== "E" /* Stderr */) {
80
+ else if (this._abridgedStderr && chunk.kind !== "E" /* TerminalChunkKind.Stderr */) {
81
81
  // If we're capturing stderr, then ignore non-stderr input
82
82
  return;
83
83
  }
@@ -1 +1 @@
1
- {"version":3,"file":"StdioSummarizer.js","sourceRoot":"","sources":["../src/StdioSummarizer.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,yDAAsD;AAoBtD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,eAAgB,SAAQ,mCAAgB;IAYnD,YAAmB,OAAiC;QAClD,KAAK,EAAE,CAAC;QAJF,0BAAqB,GAAW,CAAC,CAAC;QAMxC,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QAED,IAAI,CA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,KAAK,CAAC,IAAI,CAAC,CAC7B,CAAC;SACH;QAED,IAAI,KAAK,CAAC,IAAI,qBAA6B,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACpE,2DAA2D;YAC3D,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;YAC5B,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;YACjC,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC;YAClC,IAAI,CAAC,qBAAqB,GAAG,CAAC,CAAC;SAChC;aAAM,IAAI,IAAI,CAAC,eAAe,IAAI,KAAK,CAAC,IAAI,qBAA6B,EAAE;YAC1E,0DAA0D;YAC1D,OAAO;SACR;QAED,uCAAuC;QACvC,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE;YACrD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACvC,OAAO;SACR;QAED,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAExC,yDAAyD;QACzD,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE;YAC1D,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;YAC/B,EAAE,IAAI,CAAC,qBAAqB,CAAC;SAC9B;IACH,CAAC;CACF;AAlFD,0CAkFC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { ITerminalChunk, TerminalChunkKind } from './ITerminalChunk';\nimport { TerminalWritable } from './TerminalWritable';\n\n/**\n * Constructor options for {@link StdioSummarizer}.\n * @beta\n */\nexport interface IStdioSummarizerOptions {\n /**\n * Specifies the maximum number of leading lines to include in the summary.\n * @defaultValue `10`\n */\n leadingLines?: number;\n\n /**\n * Specifies the maximum number of trailing lines to include in the summary.\n * @defaultValue `10`\n */\n trailingLines?: number;\n}\n\n/**\n * Summarizes the results of a failed build task by returning a subset of `stderr` output not to exceed\n * a specified maximum number of lines.\n *\n * @remarks\n * IMPORTANT: This transform assumes that its input was prepared by {@link StderrLineTransform}, so that each\n * {@link ITerminalChunk.text} item is a single line terminated by a `\"\\n\"` character.\n *\n * The {@link IStdioSummarizerOptions.leadingLines} and {@link IStdioSummarizerOptions.trailingLines}\n * counts specify the maximum number of lines to be returned. Any additional lines will be omitted.\n * For example, if `leadingLines` and `trailingLines` were set to `3`, then the summary of 16 `stderr` lines might\n * look like this:\n *\n * ```\n * Line 1\n * Line 2\n * Line 3\n * ...10 lines omitted...\n * Line 14\n * Line 15\n * Line 16\n * ```\n *\n * If the `stderr` output is completely empty, then the `stdout` output will be summarized instead.\n *\n * @beta\n */\nexport class StdioSummarizer extends TerminalWritable {\n // Capture up to this many leading lines\n private _leadingLines: number;\n\n // Capture up to this many trailing lines\n private _trailingLines: number;\n\n private readonly _abridgedLeading: string[];\n private readonly _abridgedTrailing: string[];\n private _abridgedOmittedLines: number = 0;\n private _abridgedStderr: boolean;\n\n public constructor(options?: IStdioSummarizerOptions) {\n super();\n\n if (!options) {\n options = {};\n }\n\n this._leadingLines = options.leadingLines !== undefined ? options.leadingLines : 10;\n this._trailingLines = options.trailingLines !== undefined ? options.trailingLines : 10;\n\n this._abridgedLeading = [];\n this._abridgedTrailing = [];\n this._abridgedStderr = false;\n }\n\n /**\n * Returns the summary report.\n *\n * @remarks\n * The `close()` method must be called before `getReport()` can be used.\n */\n public getReport(): string {\n if (this.isOpen) {\n throw new Error('The summary cannot be prepared until after close() is called.');\n }\n const report: string[] = [...this._abridgedLeading];\n if (this._abridgedOmittedLines === 1) {\n report.push(` ...${this._abridgedOmittedLines} line omitted...\\n`);\n }\n if (this._abridgedOmittedLines > 1) {\n report.push(` ...${this._abridgedOmittedLines} lines omitted...\\n`);\n }\n report.push(...this._abridgedTrailing);\n return report.join('');\n }\n\n public onWriteChunk(chunk: ITerminalChunk): void {\n if (chunk.text.length === 0 || chunk.text[chunk.text.length - 1] !== '\\n') {\n throw new Error(\n 'StdioSummarizer expects chunks that were separated parsed into lines by StderrLineTransform\\n' +\n ' Invalid input: ' +\n JSON.stringify(chunk.text)\n );\n }\n\n if (chunk.kind === TerminalChunkKind.Stderr && !this._abridgedStderr) {\n // The first time we see stderr, switch to capturing stderr\n this._abridgedStderr = true;\n this._abridgedLeading.length = 0;\n this._abridgedTrailing.length = 0;\n this._abridgedOmittedLines = 0;\n } else if (this._abridgedStderr && chunk.kind !== TerminalChunkKind.Stderr) {\n // If we're capturing stderr, then ignore non-stderr input\n return;\n }\n\n // Did we capture enough leading lines?\n if (this._abridgedLeading.length < this._leadingLines) {\n this._abridgedLeading.push(chunk.text);\n return;\n }\n\n this._abridgedTrailing.push(chunk.text);\n\n // If we captured to many trailing lines, omit the extras\n while (this._abridgedTrailing.length > this._trailingLines) {\n this._abridgedTrailing.shift();\n ++this._abridgedOmittedLines;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"StdioSummarizer.js","sourceRoot":"","sources":["../src/StdioSummarizer.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,yDAAsD;AAoBtD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,eAAgB,SAAQ,mCAAgB;IAYnD,YAAmB,OAAiC;QAClD,KAAK,EAAE,CAAC;QAJF,0BAAqB,GAAW,CAAC,CAAC;QAMxC,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QAED,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;QACpF,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CA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jC,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC;YAClC,IAAI,CAAC,qBAAqB,GAAG,CAAC,CAAC;SAChC;aAAM,IAAI,IAAI,CAAC,eAAe,IAAI,KAAK,CAAC,IAAI,uCAA6B,EAAE;YAC1E,0DAA0D;YAC1D,OAAO;SACR;QAED,uCAAuC;QACvC,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE;YACrD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACvC,OAAO;SACR;QAED,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAExC,yDAAyD;QACzD,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE;YAC1D,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;YAC/B,EAAE,IAAI,CAAC,qBAAqB,CAAC;SAC9B;IACH,CAAC;CACF;AAlFD,0CAkFC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { ITerminalChunk, TerminalChunkKind } from './ITerminalChunk';\nimport { TerminalWritable } from './TerminalWritable';\n\n/**\n * Constructor options for {@link StdioSummarizer}.\n * @beta\n */\nexport interface IStdioSummarizerOptions {\n /**\n * Specifies the maximum number of leading lines to include in the summary.\n * @defaultValue `10`\n */\n leadingLines?: number;\n\n /**\n * Specifies the maximum number of trailing lines to include in the summary.\n * @defaultValue `10`\n */\n trailingLines?: number;\n}\n\n/**\n * Summarizes the results of a failed build task by returning a subset of `stderr` output not to exceed\n * a specified maximum number of lines.\n *\n * @remarks\n * IMPORTANT: This transform assumes that its input was prepared by {@link StderrLineTransform}, so that each\n * {@link ITerminalChunk.text} item is a single line terminated by a `\"\\n\"` character.\n *\n * The {@link IStdioSummarizerOptions.leadingLines} and {@link IStdioSummarizerOptions.trailingLines}\n * counts specify the maximum number of lines to be returned. Any additional lines will be omitted.\n * For example, if `leadingLines` and `trailingLines` were set to `3`, then the summary of 16 `stderr` lines might\n * look like this:\n *\n * ```\n * Line 1\n * Line 2\n * Line 3\n * ...10 lines omitted...\n * Line 14\n * Line 15\n * Line 16\n * ```\n *\n * If the `stderr` output is completely empty, then the `stdout` output will be summarized instead.\n *\n * @beta\n */\nexport class StdioSummarizer extends TerminalWritable {\n // Capture up to this many leading lines\n private _leadingLines: number;\n\n // Capture up to this many trailing lines\n private _trailingLines: number;\n\n private readonly _abridgedLeading: string[];\n private readonly _abridgedTrailing: string[];\n private _abridgedOmittedLines: number = 0;\n private _abridgedStderr: boolean;\n\n public constructor(options?: IStdioSummarizerOptions) {\n super();\n\n if (!options) {\n options = {};\n }\n\n this._leadingLines = options.leadingLines !== undefined ? options.leadingLines : 10;\n this._trailingLines = options.trailingLines !== undefined ? options.trailingLines : 10;\n\n this._abridgedLeading = [];\n this._abridgedTrailing = [];\n this._abridgedStderr = false;\n }\n\n /**\n * Returns the summary report.\n *\n * @remarks\n * The `close()` method must be called before `getReport()` can be used.\n */\n public getReport(): string {\n if (this.isOpen) {\n throw new Error('The summary cannot be prepared until after close() is called.');\n }\n const report: string[] = [...this._abridgedLeading];\n if (this._abridgedOmittedLines === 1) {\n report.push(` ...${this._abridgedOmittedLines} line omitted...\\n`);\n }\n if (this._abridgedOmittedLines > 1) {\n report.push(` ...${this._abridgedOmittedLines} lines omitted...\\n`);\n }\n report.push(...this._abridgedTrailing);\n return report.join('');\n }\n\n public onWriteChunk(chunk: ITerminalChunk): void {\n if (chunk.text.length === 0 || chunk.text[chunk.text.length - 1] !== '\\n') {\n throw new Error(\n 'StdioSummarizer expects chunks that were separated parsed into lines by StderrLineTransform\\n' +\n ' Invalid input: ' +\n JSON.stringify(chunk.text)\n );\n }\n\n if (chunk.kind === TerminalChunkKind.Stderr && !this._abridgedStderr) {\n // The first time we see stderr, switch to capturing stderr\n this._abridgedStderr = true;\n this._abridgedLeading.length = 0;\n this._abridgedTrailing.length = 0;\n this._abridgedOmittedLines = 0;\n } else if (this._abridgedStderr && chunk.kind !== TerminalChunkKind.Stderr) {\n // If we're capturing stderr, then ignore non-stderr input\n return;\n }\n\n // Did we capture enough leading lines?\n if (this._abridgedLeading.length < this._leadingLines) {\n this._abridgedLeading.push(chunk.text);\n return;\n }\n\n this._abridgedTrailing.push(chunk.text);\n\n // If we captured to many trailing lines, omit the extras\n while (this._abridgedTrailing.length > this._trailingLines) {\n this._abridgedTrailing.shift();\n ++this._abridgedOmittedLines;\n }\n }\n}\n"]}
@@ -20,10 +20,10 @@ const TerminalWritable_1 = require("./TerminalWritable");
20
20
  */
21
21
  class StdioWritable extends TerminalWritable_1.TerminalWritable {
22
22
  onWriteChunk(chunk) {
23
- if (chunk.kind === "O" /* Stdout */) {
23
+ if (chunk.kind === "O" /* TerminalChunkKind.Stdout */) {
24
24
  process_1.default.stdout.write(chunk.text);
25
25
  }
26
- else if (chunk.kind === "E" /* Stderr */) {
26
+ else if (chunk.kind === "E" /* TerminalChunkKind.Stderr */) {
27
27
  process_1.default.stderr.write(chunk.text);
28
28
  }
29
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"StdioWritable.js","sourceRoot":"","sources":["../src/StdioWritable.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,sDAA8B;AAE9B,yDAAsD;AAEtD;;;;;;;;;GASG;AACH,MAAa,aAAc,SAAQ,mCAAgB;IAGvC,YAAY,CAAC,KAAqB;QAC1C,IAAI,KAAK,CAAC,IAAI,qBAA6B,EAAE;YAC3C,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAClC;aAAM,IAAI,KAAK,CAAC,IAAI,qBAA6B,EAAE;YAClD,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAClC;IACH,CAAC;;AATH,sCAUC;AATe,sBAAQ,GAAkB,IAAI,aAAa,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport process from 'process';\nimport { ITerminalChunk, TerminalChunkKind } from './ITerminalChunk';\nimport { TerminalWritable } from './TerminalWritable';\n\n/**\n * A {@link TerminalWritable} subclass that writes its output directly to the process `stdout` and `stderr`\n * streams.\n *\n * @remarks\n * This is the standard output target for a process. You normally do not need to construct\n * this class; the {@link StdioWritable.\"instance\"} singleton can be used instead.\n *\n * @public\n */\nexport class StdioWritable extends TerminalWritable {\n public static instance: StdioWritable = new StdioWritable();\n\n protected onWriteChunk(chunk: ITerminalChunk): void {\n if (chunk.kind === TerminalChunkKind.Stdout) {\n process.stdout.write(chunk.text);\n } else if (chunk.kind === TerminalChunkKind.Stderr) {\n process.stderr.write(chunk.text);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"StdioWritable.js","sourceRoot":"","sources":["../src/StdioWritable.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,sDAA8B;AAE9B,yDAAsD;AAEtD;;;;;;;;;GASG;AACH,MAAa,aAAc,SAAQ,mCAAgB;IAGvC,YAAY,CAAC,KAAqB;QAC1C,IAAI,KAAK,CAAC,IAAI,uCAA6B,EAAE;YAC3C,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAClC;aAAM,IAAI,KAAK,CAAC,IAAI,uCAA6B,EAAE;YAClD,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAClC;IACH,CAAC;;AATH,sCAUC;AATe,sBAAQ,GAAkB,IAAI,aAAa,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport process from 'process';\nimport { ITerminalChunk, TerminalChunkKind } from './ITerminalChunk';\nimport { TerminalWritable } from './TerminalWritable';\n\n/**\n * A {@link TerminalWritable} subclass that writes its output directly to the process `stdout` and `stderr`\n * streams.\n *\n * @remarks\n * This is the standard output target for a process. You normally do not need to construct\n * this class; the {@link StdioWritable.\"instance\"} singleton can be used instead.\n *\n * @public\n */\nexport class StdioWritable extends TerminalWritable {\n public static instance: StdioWritable = new StdioWritable();\n\n protected onWriteChunk(chunk: ITerminalChunk): void {\n if (chunk.kind === TerminalChunkKind.Stdout) {\n process.stdout.write(chunk.text);\n } else if (chunk.kind === TerminalChunkKind.Stderr) {\n process.stderr.write(chunk.text);\n }\n }\n}\n"]}
@@ -38,10 +38,10 @@ class TextRewriterTransform extends TerminalTransform_1.TerminalTransform {
38
38
  this._stdoutStates = this.textRewriters.map((x) => x.initialize());
39
39
  }
40
40
  onWriteChunk(chunk) {
41
- if (chunk.kind === "E" /* Stderr */) {
41
+ if (chunk.kind === "E" /* TerminalChunkKind.Stderr */) {
42
42
  this._processText(chunk, this._stderrStates);
43
43
  }
44
- else if (chunk.kind === "O" /* Stdout */) {
44
+ else if (chunk.kind === "O" /* TerminalChunkKind.Stdout */) {
45
45
  this._processText(chunk, this._stdoutStates);
46
46
  }
47
47
  else {
@@ -84,8 +84,8 @@ class TextRewriterTransform extends TerminalTransform_1.TerminalTransform {
84
84
  }
85
85
  }
86
86
  onClose() {
87
- this._closeRewriters(this._stderrStates, "E" /* Stderr */);
88
- this._closeRewriters(this._stderrStates, "O" /* Stdout */);
87
+ this._closeRewriters(this._stderrStates, "E" /* TerminalChunkKind.Stderr */);
88
+ this._closeRewriters(this._stderrStates, "O" /* TerminalChunkKind.Stdout */);
89
89
  this.autocloseDestination();
90
90
  }
91
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TextRewriterTransform.js","sourceRoot":"","sources":["../src/TextRewriterTransform.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAK3D,2DAAmF;A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I,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC;gBAC1B,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,SAAS;aAChB,CAAC,CAAC;SACJ;IACH,CAAC;IAES,OAAO;QACf,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,mBAA2B,CAAC;QACnE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,mBAA2B,CAAC;QAEnE,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;CACF;AArFD,sDAqFC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { NewlineKind } from '@rushstack/node-core-library';\n\nimport { ITerminalChunk, TerminalChunkKind } from './ITerminalChunk';\nimport { TerminalTransform, ITerminalTransformOptions } from './TerminalTransform';\nimport { TextRewriter, TextRewriterState } from './TextRewriter';\nimport { RemoveColorsTextRewriter } from './RemoveColorsTextRewriter';\nimport { NormalizeNewlinesTextRewriter } from './NormalizeNewlinesTextRewriter';\n\n/**\n * Constructor options for {@link TextRewriterTransform}.\n *\n * @public\n */\nexport interface ITextRewriterTransformOptions extends ITerminalTransformOptions {\n /**\n * A list of rewriters to be applied. More items may be appended to the list, for example\n * if {@link ITextRewriterTransformOptions.removeColors} is specified.\n *\n * @remarks\n * The final list must contain at least one item.\n */\n textRewriters?: TextRewriter[];\n\n /**\n * If specified, a {@link RemoveColorsTextRewriter} will be appended to the list of rewriters.\n */\n removeColors?: boolean;\n\n /**\n * If `normalizeNewlines` or `ensureNewlineAtEnd` is specified, a {@link NormalizeNewlinesTextRewriter}\n * will be appended to the list of rewriters with the specified settings.\n *\n * @remarks\n * See {@link INormalizeNewlinesTextRewriterOptions} for details.\n */\n normalizeNewlines?: NewlineKind;\n\n /**\n * If `normalizeNewlines` or `ensureNewlineAtEnd` is specified, a {@link NormalizeNewlinesTextRewriter}\n * will be appended to the list of rewriters with the specified settings.\n *\n * @remarks\n * See {@link INormalizeNewlinesTextRewriterOptions} for details.\n */\n ensureNewlineAtEnd?: boolean;\n}\n\n/**\n * A {@link TerminalTransform} subclass that performs one or more {@link TextRewriter} operations.\n * The most common operations are {@link NormalizeNewlinesTextRewriter} and {@link RemoveColorsTextRewriter}.\n *\n * @remarks\n * The `TextRewriter` operations are applied separately to the `stderr` and `stdout` streams.\n * If multiple {@link ITextRewriterTransformOptions.textRewriters} are configured, they are applied\n * in the order that they appear in the array.\n *\n * @public\n */\nexport class TextRewriterTransform extends TerminalTransform {\n private readonly _stderrStates: TextRewriterState[];\n private readonly _stdoutStates: TextRewriterState[];\n\n public readonly textRewriters: ReadonlyArray<TextRewriter>;\n\n public constructor(options: ITextRewriterTransformOptions) {\n super(options);\n\n const textRewriters: TextRewriter[] = options.textRewriters || [];\n\n if (options.removeColors) {\n textRewriters.push(new RemoveColorsTextRewriter());\n }\n if (options.normalizeNewlines) {\n textRewriters.push(\n new NormalizeNewlinesTextRewriter({\n newlineKind: options.normalizeNewlines,\n ensureNewlineAtEnd: options.ensureNewlineAtEnd\n })\n );\n }\n\n if (textRewriters.length === 0) {\n throw new Error('TextRewriterTransform requires at least one matcher');\n }\n\n this.textRewriters = textRewriters;\n\n this._stderrStates = this.textRewriters.map((x) => x.initialize());\n this._stdoutStates = this.textRewriters.map((x) => x.initialize());\n }\n\n protected onWriteChunk(chunk: ITerminalChunk): void {\n if (chunk.kind === TerminalChunkKind.Stderr) {\n this._processText(chunk, this._stderrStates);\n } else if (chunk.kind === TerminalChunkKind.Stdout) {\n this._processText(chunk, this._stdoutStates);\n } else {\n this.destination.writeChunk(chunk);\n }\n }\n\n private _processText(chunk: ITerminalChunk, states: TextRewriterState[]): void {\n let text: string = chunk.text;\n for (let i: number = 0; i < states.length; ++i) {\n if (text.length > 0) {\n text = this.textRewriters[i].process(states[i], text);\n }\n }\n if (text.length > 0) {\n // If possible, avoid allocating a new chunk\n if (text === chunk.text) {\n this.destination.writeChunk(chunk);\n } else {\n this.destination.writeChunk({\n text: text,\n kind: chunk.kind\n });\n }\n }\n }\n\n private _closeRewriters(states: TextRewriterState[], chunkKind: TerminalChunkKind): void {\n let text: string = '';\n for (let i: number = 0; i < states.length; ++i) {\n if (text.length > 0) {\n text = this.textRewriters[i].process(states[i], text);\n }\n text += this.textRewriters[i].close(states[i]);\n }\n if (text.length > 0) {\n this.destination.writeChunk({\n text: text,\n kind: chunkKind\n });\n }\n }\n\n protected onClose(): void {\n this._closeRewriters(this._stderrStates, TerminalChunkKind.Stderr);\n this._closeRewriters(this._stderrStates, TerminalChunkKind.Stdout);\n\n this.autocloseDestination();\n }\n}\n"]}
1
+ {"version":3,"file":"TextRewriterTransform.js","sourceRoot":"","sources":["../src/TextRewriterTransform.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAK3D,2DAAmF;AAEnF,yEAAsE;AACtE,mFAAgF;AAyChF;;;;;;;;;;GAUG;AACH,MAAa,qBAAsB,SAAQ,qCAAiB;IAM1D,YAAmB,OAAsC;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,MAAM,aAAa,GAAmB,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC;QAElE,IAAI,OAAO,CAAC,YAAY,EAAE;YACxB,aAAa,CAAC,IAAI,CAAC,IAAI,mDAAwB,EAAE,CAAC,CAAC;SACpD;QACD,IAAI,OAAO,CAAC,iBAAiB,EAAE;YAC7B,aAAa,CAAC,IAAI,CAChB,IAAI,6DAA6B,CAAC;gBAChC,WAAW,EAAE,OAAO,CAAC,iBAAiB;gBACtC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;aAC/C,CAAC,CACH,CAAC;SACH;QAED,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;SACxE;QAED,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QAEnC,IAAI,CAAC,aAAa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ACV,IAAI,EAAE,KAAK,CAAC,IAAI;iBACjB,CAAC,CAAC;aACJ;SACF;IACH,CAAC;IAEO,eAAe,CAAC,MAA2B,EAAE,SAA4B;QAC/E,IAAI,IAAI,GAAW,EAAE,CAAC;QACtB,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YAC9C,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;gBACnB,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;aACvD;YACD,IAAI,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SAChD;QACD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YACnB,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC;gBAC1B,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,SAAS;aAChB,CAAC,CAAC;SACJ;IACH,CAAC;IAES,OAAO;QACf,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,qCAA2B,CAAC;QACnE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,qCAA2B,CAAC;QAEnE,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;CACF;AArFD,sDAqFC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { NewlineKind } from '@rushstack/node-core-library';\n\nimport { ITerminalChunk, TerminalChunkKind } from './ITerminalChunk';\nimport { TerminalTransform, ITerminalTransformOptions } from './TerminalTransform';\nimport { TextRewriter, TextRewriterState } from './TextRewriter';\nimport { RemoveColorsTextRewriter } from './RemoveColorsTextRewriter';\nimport { NormalizeNewlinesTextRewriter } from './NormalizeNewlinesTextRewriter';\n\n/**\n * Constructor options for {@link TextRewriterTransform}.\n *\n * @public\n */\nexport interface ITextRewriterTransformOptions extends ITerminalTransformOptions {\n /**\n * A list of rewriters to be applied. More items may be appended to the list, for example\n * if {@link ITextRewriterTransformOptions.removeColors} is specified.\n *\n * @remarks\n * The final list must contain at least one item.\n */\n textRewriters?: TextRewriter[];\n\n /**\n * If specified, a {@link RemoveColorsTextRewriter} will be appended to the list of rewriters.\n */\n removeColors?: boolean;\n\n /**\n * If `normalizeNewlines` or `ensureNewlineAtEnd` is specified, a {@link NormalizeNewlinesTextRewriter}\n * will be appended to the list of rewriters with the specified settings.\n *\n * @remarks\n * See {@link INormalizeNewlinesTextRewriterOptions} for details.\n */\n normalizeNewlines?: NewlineKind;\n\n /**\n * If `normalizeNewlines` or `ensureNewlineAtEnd` is specified, a {@link NormalizeNewlinesTextRewriter}\n * will be appended to the list of rewriters with the specified settings.\n *\n * @remarks\n * See {@link INormalizeNewlinesTextRewriterOptions} for details.\n */\n ensureNewlineAtEnd?: boolean;\n}\n\n/**\n * A {@link TerminalTransform} subclass that performs one or more {@link TextRewriter} operations.\n * The most common operations are {@link NormalizeNewlinesTextRewriter} and {@link RemoveColorsTextRewriter}.\n *\n * @remarks\n * The `TextRewriter` operations are applied separately to the `stderr` and `stdout` streams.\n * If multiple {@link ITextRewriterTransformOptions.textRewriters} are configured, they are applied\n * in the order that they appear in the array.\n *\n * @public\n */\nexport class TextRewriterTransform extends TerminalTransform {\n private readonly _stderrStates: TextRewriterState[];\n private readonly _stdoutStates: TextRewriterState[];\n\n public readonly textRewriters: ReadonlyArray<TextRewriter>;\n\n public constructor(options: ITextRewriterTransformOptions) {\n super(options);\n\n const textRewriters: TextRewriter[] = options.textRewriters || [];\n\n if (options.removeColors) {\n textRewriters.push(new RemoveColorsTextRewriter());\n }\n if (options.normalizeNewlines) {\n textRewriters.push(\n new NormalizeNewlinesTextRewriter({\n newlineKind: options.normalizeNewlines,\n ensureNewlineAtEnd: options.ensureNewlineAtEnd\n })\n );\n }\n\n if (textRewriters.length === 0) {\n throw new Error('TextRewriterTransform requires at least one matcher');\n }\n\n this.textRewriters = textRewriters;\n\n this._stderrStates = this.textRewriters.map((x) => x.initialize());\n this._stdoutStates = this.textRewriters.map((x) => x.initialize());\n }\n\n protected onWriteChunk(chunk: ITerminalChunk): void {\n if (chunk.kind === TerminalChunkKind.Stderr) {\n this._processText(chunk, this._stderrStates);\n } else if (chunk.kind === TerminalChunkKind.Stdout) {\n this._processText(chunk, this._stdoutStates);\n } else {\n this.destination.writeChunk(chunk);\n }\n }\n\n private _processText(chunk: ITerminalChunk, states: TextRewriterState[]): void {\n let text: string = chunk.text;\n for (let i: number = 0; i < states.length; ++i) {\n if (text.length > 0) {\n text = this.textRewriters[i].process(states[i], text);\n }\n }\n if (text.length > 0) {\n // If possible, avoid allocating a new chunk\n if (text === chunk.text) {\n this.destination.writeChunk(chunk);\n } else {\n this.destination.writeChunk({\n text: text,\n kind: chunk.kind\n });\n }\n }\n }\n\n private _closeRewriters(states: TextRewriterState[], chunkKind: TerminalChunkKind): void {\n let text: string = '';\n for (let i: number = 0; i < states.length; ++i) {\n if (text.length > 0) {\n text = this.textRewriters[i].process(states[i], text);\n }\n text += this.textRewriters[i].close(states[i]);\n }\n if (text.length > 0) {\n this.destination.writeChunk({\n text: text,\n kind: chunkKind\n });\n }\n }\n\n protected onClose(): void {\n this._closeRewriters(this._stderrStates, TerminalChunkKind.Stderr);\n this._closeRewriters(this._stderrStates, TerminalChunkKind.Stdout);\n\n this.autocloseDestination();\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/terminal",
3
- "version": "0.3.59",
3
+ "version": "0.3.62",
4
4
  "description": "User interface primitives for console applications",
5
5
  "main": "lib/index.js",
6
6
  "typings": "dist/terminal.d.ts",
@@ -11,14 +11,14 @@
11
11
  "directory": "libraries/terminal"
12
12
  },
13
13
  "dependencies": {
14
- "@rushstack/node-core-library": "3.49.0",
14
+ "@rushstack/node-core-library": "3.50.1",
15
15
  "@types/node": "12.20.24",
16
16
  "wordwrap": "~1.0.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@rushstack/eslint-config": "2.6.2",
20
- "@rushstack/heft": "0.46.5",
21
- "@rushstack/heft-node-rig": "1.9.21",
19
+ "@rushstack/eslint-config": "3.0.0",
20
+ "@rushstack/heft": "0.47.0",
21
+ "@rushstack/heft-node-rig": "1.10.0",
22
22
  "@types/heft-jest": "1.0.1",
23
23
  "@types/wordwrap": "~1.0.0",
24
24
  "colors": "~1.2.1"