Skip to content

Commit 3193d51

Browse files
committed
fix(cli): resolve TypeScript error in shadowNpmBase cwd handling
Extracted cwd from destructuring to avoid type conflict when spreading spawnOpts. This ensures cwd is properly typed as string after URL-to-path conversion and prevents TypeScript error about assigning {} to string | URL | undefined. Also removed unnecessary type cast in findUp call since cwd is now correctly typed as string.
1 parent 9557cea commit 3193d51

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/cli/src/shadow/npm-base.mts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ export default async function shadowNpmBase(
6565
extra?: SpawnExtra | undefined,
6666
): Promise<ShadowBinResult> {
6767
const {
68+
cwd: cwdOption,
6869
env: spawnEnv,
6970
ipc,
7071
...spawnOpts
7172
} = { __proto__: null, ...options } as ShadowBinOptions
7273

73-
let cwd = getOwn(spawnOpts, 'cwd') ?? process.cwd()
74+
let cwd = cwdOption ?? process.cwd()
7475
if (cwd instanceof URL) {
7576
cwd = normalizePath(fileURLToPath(cwd))
7677
} else if (typeof cwd === 'string') {
@@ -143,7 +144,7 @@ export default async function shadowNpmBase(
143144
const logLevelArgs = isSilent ? [FLAG_LOGLEVEL, 'error'] : []
144145
const noAuditArgs =
145146
useAudit ||
146-
!(await findUp(NODE_MODULES, { cwd: cwd as string, onlyDirectories: true }))
147+
!(await findUp(NODE_MODULES, { cwd, onlyDirectories: true }))
147148
? []
148149
: ['--no-audit']
149150

0 commit comments

Comments
 (0)