Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const typescriptTemplate = {
devDependencies: {
'@types/node': cliPkg.devDependencies['@types/node'],
c8: cliPkg.devDependencies.c8,
'cross-env': cliPkg.devDependencies['cross-env'],
'ts-node': cliPkg.devDependencies['ts-node'],
concurrently: cliPkg.devDependencies.concurrently,
'fastify-tsconfig': cliPkg.devDependencies['fastify-tsconfig'],
Expand Down Expand Up @@ -168,7 +169,7 @@ function cli (args) {
template.type = 'module'

template.devDependencies.c8 = cliPkg.devDependencies.c8
template.scripts.test = 'npm run build:ts && tsc -p test/tsconfig.json && FASTIFY_AUTOLOAD_TYPESCRIPT=1 node --test --experimental-test-coverage --loader ts-node/esm test/**/*.ts'
template.scripts.test = 'npm run build:ts && tsc -p test/tsconfig.json && cross-env FASTIFY_AUTOLOAD_TYPESCRIPT=1 node --test --experimental-test-coverage --loader ts-node/esm test/**/*.ts'
template.scripts.dev = 'fastify start -w -l info src/app.ts'
delete template.scripts['dev:start']
}
Expand Down
7 changes: 4 additions & 3 deletions test/generate-typescript-esm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const expected = {}
const initVersion = execSync('npm get init-version').toString().trim()

typescriptTemplate.type = 'module'
typescriptTemplate.scripts.test = 'npm run build:ts && tsc -p test/tsconfig.json && FASTIFY_AUTOLOAD_TYPESCRIPT=1 node --test --experimental-test-coverage --loader ts-node/esm test/**/*.ts'
typescriptTemplate.scripts.test = 'npm run build:ts && tsc -p test/tsconfig.json && cross-env FASTIFY_AUTOLOAD_TYPESCRIPT=1 node --test --experimental-test-coverage --loader ts-node/esm test/**/*.ts'

;(function (cb) {
const files = []
Expand Down Expand Up @@ -131,7 +131,7 @@ 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 && FASTIFY_AUTOLOAD_TYPESCRIPT=1 node --test --experimental-test-coverage --loader ts-node/esm test/**/*.ts')
t.assert.strictEqual(pkg.scripts.test, 'npm run build:ts && tsc -p test/tsconfig.json && cross-env FASTIFY_AUTOLOAD_TYPESCRIPT=1 node --test --experimental-test-coverage --loader ts-node/esm test/**/*.ts')
t.assert.strictEqual(pkg.scripts.start, 'npm run build:ts && fastify start -l info dist/app.js')
t.assert.strictEqual(pkg.scripts['build:ts'], 'tsc')
t.assert.strictEqual(pkg.scripts['watch:ts'], 'tsc -w')
Expand All @@ -144,10 +144,11 @@ function define (t) {
t.assert.strictEqual(pkg.dependencies['@fastify/sensible'], cliPkg.devDependencies['@fastify/sensible'])
t.assert.strictEqual(pkg.devDependencies['@types/node'], cliPkg.devDependencies['@types/node'])
t.assert.strictEqual(pkg.devDependencies['ts-node'], cliPkg.devDependencies['ts-node'])
t.assert.strictEqual(pkg.devDependencies['cross-env'], cliPkg.devDependencies['cross-env'])
t.assert.strictEqual(pkg.devDependencies.concurrently, cliPkg.devDependencies.concurrently)
t.assert.strictEqual(pkg.devDependencies.typescript, cliPkg.devDependencies.typescript)

const testGlob = pkg.scripts.test.split(' ', 15)[14]
const testGlob = pkg.scripts.test.match(/"?test\/\*\*\/\*\.ts"?$/)[0].replaceAll('"', '')

t.assert.strictEqual(minimatch.match(['test/routes/plugins/more/test/here/ok.test.ts'], testGlob).length, 1)
resolve()
Expand Down
3 changes: 2 additions & 1 deletion test/generate-typescript.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,12 @@ function define (t) {
t.assert.strictEqual(pkg.dependencies['@fastify/sensible'], cliPkg.devDependencies['@fastify/sensible'])
t.assert.strictEqual(pkg.devDependencies['@types/node'], cliPkg.devDependencies['@types/node'])
t.assert.strictEqual(pkg.devDependencies.c8, cliPkg.devDependencies.c8)
t.assert.strictEqual(pkg.devDependencies['cross-env'], cliPkg.devDependencies['cross-env'])
t.assert.strictEqual(pkg.devDependencies['ts-node'], cliPkg.devDependencies['ts-node'])
t.assert.strictEqual(pkg.devDependencies.concurrently, cliPkg.devDependencies.concurrently)
t.assert.strictEqual(pkg.devDependencies.typescript, cliPkg.devDependencies.typescript)

const testGlob = pkg.scripts.test.split(' ', 14)[13].replaceAll('"', '')
const testGlob = pkg.scripts.test.match(/"?test\/\*\*\/\*\.ts"?$/)[0].replaceAll('"', '')

t.assert.strictEqual(minimatch.match(['test/routes/plugins/more/test/here/ok.test.ts'], testGlob).length, 1, 'should match glob')
resolve()
Expand Down
Loading