From 2850f77dc7f1d1a108b65095a2ed6d950d7701d2 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 29 Nov 2023 12:43:01 +0100 Subject: [PATCH] Fix possible crash on `--watch` --- lib/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index 53b604c..d9234c4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -6,7 +6,6 @@ * @typedef {import('./parse-argv.js').State} State */ -import assert from 'node:assert/strict' import process from 'node:process' import stream from 'node:stream' import {fileURLToPath} from 'node:url' @@ -144,10 +143,14 @@ export function args(options) { ? fileURLToPath(state.engine.cwd) : state.engine.cwd - assert(typeof cwd === 'string', '`cwd` is defined') - watcher = chokidar - .watch(urls, {cwd, ignoreInitial: true}) + .watch( + urls, + // @ts-expect-error: chokidar types are wrong w/ + // `exactOptionalPropertyTypes`, + // `cwd` can be `undefined`. + {cwd, ignoreInitial: true} + ) .on('error', done) .on('change', function (filePath) { state.engine.files = [filePath]