From ba6be613392431cca58c40916e4105eb951a83ae Mon Sep 17 00:00:00 2001 From: Joao Paulo Furtado Date: Thu, 5 Nov 2026 13:32:33 -0700 Subject: [PATCH] fix(watch): refuse a busy output folder before looking for tools CI caught the order: a machine without yt-dlp reported the missing tool when the real complaint was a non-empty --out. Argument checks now run before tool discovery, so the first error a caller sees is the one they caused. --- scripts/watch.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/watch.mjs b/scripts/watch.mjs index 744ab5c..d043d90 100644 --- a/scripts/watch.mjs +++ b/scripts/watch.mjs @@ -163,13 +163,13 @@ export async function watch(args) { const options = parseArgs(args); if (options.help) { console.log(usage); return; } if (!options.query) throw new Error(`missing search words\n\n${usage}`); - const ytDlp = tool('yt-dlp', 'install it with `pipx install yt-dlp`'); - const ffmpeg = tool('ffmpeg'); const folder = options.out ? path.resolve(options.out) : mkdtempSync(path.join(os.tmpdir(), 'threenative-watch-')); if (options.out) { if (existsSync(folder) && readdirSync(folder).length) throw new Error(`output folder is not empty: ${folder}`); mkdirSync(folder, { recursive: true }); } + const ytDlp = tool('yt-dlp', 'install it with `pipx install yt-dlp`'); + const ffmpeg = tool('ffmpeg'); const candidates = await search(ytDlp, options.query); if (!candidates.length) throw new Error(`no YouTube result for "${options.query}"`);