From a304bf262f8ca0d40735590cab8483de33ceb6b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Kr=C3=A1l?= Date: Thu, 12 Nov 2026 14:43:05 +0100 Subject: [PATCH] Run the cli-app fixture when it is invoked through its installed bin link bin/slugify.js ran only when argv[1] ended in slugify.js, so the slugify command an install creates printed nothing. Compare the real path of argv[1] with the module's own path instead. Found while fixing #24. --- tests/evals/fixtures/cli-app/repo/bin/slugify.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/evals/fixtures/cli-app/repo/bin/slugify.js b/tests/evals/fixtures/cli-app/repo/bin/slugify.js index 8148a9c..c8a85f2 100644 --- a/tests/evals/fixtures/cli-app/repo/bin/slugify.js +++ b/tests/evals/fixtures/cli-app/repo/bin/slugify.js @@ -1,4 +1,7 @@ #!/usr/bin/env node +import { realpathSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; + const HELP = `Usage: slugify [options] Options: @@ -26,6 +29,8 @@ export function run(argv) { return upper ? slug.toUpperCase() : slug; } -if (process.argv[1]?.endsWith('slugify.js')) { +// Run only when executed directly — also through the `slugify` link an install +// creates — and stay silent when a test imports `run`. +if (process.argv[1] && realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) { process.stdout.write(`${run(process.argv.slice(2))}\n`); }