From 2c757c293fd57780116520b712f222958901ce28 Mon Sep 17 00:00:00 2001 From: lalith Date: Wed, 18 Nov 2026 01:53:00 +0530 Subject: [PATCH] fix: do not quote the test glob in the TypeScript template The CommonJS TypeScript template generated a test script with a quoted glob ("test/**/*.ts"). The quotes stop the shell from expanding it, so node --test receives the pattern literally. Node.js 20 has no glob support in the test runner and fails with "Could not find '.../test/**/*.ts'". The JavaScript and ESM TypeScript templates already pass the glob unquoted; this aligns the CommonJS TypeScript one with them. Fixes #756 --- generate.js | 2 +- test/generate-typescript.test.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/generate.js b/generate.js index 535a13c3..c6f6757e 100755 --- a/generate.js +++ b/generate.js @@ -48,7 +48,7 @@ const typescriptTemplate = { main: 'app.ts', scripts: { clean: 'node -e "require(\'fs\').rmSync(\'dist\', {recursive: true, force: true})"', - test: 'npm run build:ts && tsc -p test/tsconfig.json && c8 node --test -r ts-node/register "test/**/*.ts"', + test: 'npm run build:ts && tsc -p test/tsconfig.json && c8 node --test -r ts-node/register test/**/*.ts', start: 'npm run build:ts && fastify start -l info dist/app.js', 'build:ts': 'npm run clean && tsc', 'watch:ts': 'tsc -w', diff --git a/test/generate-typescript.test.js b/test/generate-typescript.test.js index 80e52a38..e9f0ceb1 100644 --- a/test/generate-typescript.test.js +++ b/test/generate-typescript.test.js @@ -103,7 +103,7 @@ function define (t) { }) test('should finish successfully with typescript template', async (t) => { - t.plan(26 + Object.keys(expected).length) + t.plan(27 + Object.keys(expected).length) try { await generate(workdir, typescriptTemplate) await verifyPkg(t) @@ -128,7 +128,9 @@ function define (t) { // by default this will be ISC but since we have a MIT licensed pkg file in upper dir, npm will set the license to MIT in this case // so for local tests we need to accept MIT as well t.assert.ok(pkg.license === 'ISC' || pkg.license === 'MIT') - t.assert.strictEqual(pkg.scripts.test, 'npm run build:ts && tsc -p test/tsconfig.json && c8 node --test -r ts-node/register "test/**/*.ts"') + t.assert.strictEqual(pkg.scripts.test, 'npm run build:ts && tsc -p test/tsconfig.json && c8 node --test -r ts-node/register test/**/*.ts') + // the glob must not be quoted, otherwise Node.js versions without glob support in `node --test` receive it literally + t.assert.doesNotMatch(pkg.scripts.test, /["']test\/\*\*/) t.assert.strictEqual(pkg.scripts.start, 'npm run build:ts && fastify start -l info dist/app.js') t.assert.strictEqual(pkg.scripts.clean, 'node -e "require(\'fs\').rmSync(\'dist\', {recursive: true, force: true})"') t.assert.strictEqual(pkg.scripts['build:ts'], 'npm run clean && tsc')