Skip to content

Commit 512c99e

Browse files
committed
fix(deps): remove untyped dep
`stripVTControlCharacters` was added in 16.11.0 (we support >+18.14.0)
1 parent 2683ca8 commit 512c99e

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

package-lock.json

-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@
145145
"readdirp": "4.1.2",
146146
"semver": "7.7.1",
147147
"source-map-support": "0.5.21",
148-
"strip-ansi-control-characters": "2.0.0",
149148
"tempy": "3.1.0",
150149
"terminal-link": "4.0.0",
151150
"through2-filter": "4.0.0",

src/utils/shell.ts

+19-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
import process from 'process'
2+
import { Transform } from 'stream'
3+
import { stripVTControlCharacters } from 'util'
24

35
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'
66

77
import { stopSpinner, type Spinner } from '../lib/spinner.js'
8+
89
import { chalk, log, NETLIFYDEVERR, NETLIFYDEVWARN } from './command-helpers.js'
910
import { processOnExit } from './dev.js'
1011

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>)[] = []
1623

1724
let cleanupStarted = false
1825

@@ -72,12 +79,11 @@ export const runCommand = (
7279
})
7380
}
7481

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+
}
8187

8288
// we can't try->await->catch since we don't want to block on the framework server which
8389
// is a long running process

0 commit comments

Comments
 (0)