|
1 | 1 | import process from 'process'
|
| 2 | +import { Transform } from 'stream' |
| 3 | +import { stripVTControlCharacters } from 'util' |
2 | 4 |
|
3 | 5 | import execa from 'execa'
|
4 |
| -// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'stri... Remove this comment to see the full error message |
5 |
| -import stripAnsiCc from 'strip-ansi-control-characters' |
6 | 6 |
|
7 | 7 | import { stopSpinner, type Spinner } from '../lib/spinner.js'
|
| 8 | + |
8 | 9 | import { chalk, log, NETLIFYDEVERR, NETLIFYDEVWARN } from './command-helpers.js'
|
9 | 10 | import { processOnExit } from './dev.js'
|
10 | 11 |
|
11 |
| -/** |
12 |
| - * @type {(() => Promise<void>)[]} - array of functions to run before the process exits |
13 |
| - */ |
14 |
| -// @ts-expect-error TS(7034) FIXME: Variable 'cleanupWork' implicitly has type 'any[]'... Remove this comment to see the full error message |
15 |
| -const cleanupWork = [] |
| 12 | +const isErrnoException = (value: unknown): value is NodeJS.ErrnoException => |
| 13 | + value instanceof Error && Object.hasOwn(value, 'code') |
| 14 | + |
| 15 | +const createStripAnsiControlCharsStream = (): Transform => new Transform({ |
| 16 | + transform(chunk, _encoding, callback) { |
| 17 | + const text = typeof chunk === 'string' ? chunk : chunk.toString() |
| 18 | + callback(null, stripVTControlCharacters(text)) |
| 19 | + } |
| 20 | +}) |
| 21 | + |
| 22 | +const cleanupWork: (() => Promise<void>)[] = [] |
16 | 23 |
|
17 | 24 | let cleanupStarted = false
|
18 | 25 |
|
@@ -72,12 +79,11 @@ export const runCommand = (
|
72 | 79 | })
|
73 | 80 | }
|
74 | 81 |
|
75 |
| - // @ts-expect-error TS(2531) FIXME: Object is possibly 'null'. |
76 |
| - commandProcess.stdout.pipe(stripAnsiCc.stream()).on('data', pipeDataWithSpinner.bind(null, process.stdout)) |
77 |
| - // @ts-expect-error TS(2531) FIXME: Object is possibly 'null'. |
78 |
| - commandProcess.stderr.pipe(stripAnsiCc.stream()).on('data', pipeDataWithSpinner.bind(null, process.stderr)) |
79 |
| - // @ts-expect-error TS(2345) FIXME: Argument of type 'Writable | null' is not assignab... Remove this comment to see the full error message |
80 |
| - process.stdin.pipe(commandProcess.stdin) |
| 82 | + commandProcess.stdout?.pipe(createStripAnsiControlCharsStream()).on('data', pipeDataWithSpinner.bind(null, process.stdout)) |
| 83 | + commandProcess.stderr?.pipe(createStripAnsiControlCharsStream()).on('data', pipeDataWithSpinner.bind(null, process.stderr)) |
| 84 | + if (commandProcess.stdin != null) { |
| 85 | + process.stdin?.pipe(commandProcess.stdin) |
| 86 | + } |
81 | 87 |
|
82 | 88 | // we can't try->await->catch since we don't want to block on the framework server which
|
83 | 89 | // is a long running process
|
|
0 commit comments