Skip to content

Commit 330c7c6

Browse files
authored
Enhance generated VS Code configuration (#485)
1 parent fbf932f commit 330c7c6

File tree

5 files changed

+45
-16
lines changed

5 files changed

+45
-16
lines changed

generate.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ const typescriptTemplate = {
4848
test: 'npm run build:ts && tsc -p test/tsconfig.json && tap --ts test/**/*.test.ts',
4949
start: 'npm run build:ts && fastify start -l info dist/app.js',
5050
'build:ts': 'tsc',
51-
dev: 'tsc && concurrently -k -p "[{name}]" -n "TypeScript,App" -c "yellow.bold,cyan.bold" "tsc -w" "fastify start --ignore-watch=.ts$ -w -l info -P dist/app.js"'
51+
'watch:ts': 'tsc -w',
52+
dev: 'npm run build:ts && concurrently -k -p "[{name}]" -n "TypeScript,App" -c "yellow.bold,cyan.bold" "npm:watch:ts" "npm:dev:start"',
53+
'dev:start': 'fastify start --ignore-watch=.ts$ -w -l info -P dist/app.js'
5254
},
5355
dependencies: {
5456
fastify: cliPkg.dependencies.fastify,
@@ -63,7 +65,6 @@ const typescriptTemplate = {
6365
'ts-node': cliPkg.devDependencies['ts-node'],
6466
concurrently: cliPkg.devDependencies.concurrently,
6567
'fastify-tsconfig': cliPkg.devDependencies['fastify-tsconfig'],
66-
nodemon: '^2.0.15',
6768
tap: cliPkg.devDependencies.tap,
6869
typescript: cliPkg.devDependencies.typescript
6970
},

templates/app-ts/.vscode/launch.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
"version": "0.2.0",
33
"configurations": [
44
{
5-
"type": "pwa-node",
6-
"request": "launch",
5+
"type": "node",
76
"name": "Launch Fastify",
7+
"request": "launch",
8+
"runtimeArgs": [
9+
"run",
10+
"dev:start"
11+
],
12+
"runtimeExecutable": "npm",
813
"skipFiles": [
914
"<node_internals>/**"
1015
],
11-
"program": "${workspaceRoot}/node_modules/.bin/nodemon",
12-
"args": ["--exec", "npm", "run", "dev"],
13-
"preLaunchTask": "tsc: build - tsconfig.json",
14-
"outFiles": [
15-
"${workspaceFolder}/dist/**/*.js"
16-
]
16+
"console": "integratedTerminal",
17+
"preLaunchTask": "npm: watch:ts"
1718
}
1819
]
1920
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "npm",
6+
"label": "npm: watch:ts",
7+
"detail": "tsc -w",
8+
"group": {
9+
"type": "build",
10+
"isDefault": true
11+
},
12+
"script": "watch:ts",
13+
"isBackground": true,
14+
"problemMatcher": "$tsc-watch",
15+
"presentation": {
16+
"reveal": "never",
17+
"group": "watchers"
18+
}
19+
}
20+
]
21+
}

templates/app/.vscode/launch.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
"version": "0.2.0",
33
"configurations": [
44
{
5-
"type": "pwa-node",
6-
"request": "launch",
5+
"type": "node",
76
"name": "Launch Fastify",
7+
"request": "launch",
8+
"runtimeArgs": [
9+
"run",
10+
"dev"
11+
],
12+
"runtimeExecutable": "npm",
813
"skipFiles": [
914
"<node_internals>/**"
1015
],
11-
"program": "${workspaceRoot}/node_modules/.bin/fastify",
12-
"args": ["start", "-l", "info", "app.js"]
16+
"console": "integratedTerminal"
1317
}
1418
]
1519
}

test/generate-typescript.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function define (t) {
100100
})
101101

102102
test('should finish successfully with typescript template', async (t) => {
103-
t.plan(23 + Object.keys(expected).length)
103+
t.plan(25 + Object.keys(expected).length)
104104
try {
105105
await generate(workdir, typescriptTemplate)
106106
await verifyPkg(t)
@@ -128,7 +128,9 @@ function define (t) {
128128
t.equal(pkg.scripts.test, 'npm run build:ts && tsc -p test/tsconfig.json && tap --ts test/**/*.test.ts')
129129
t.equal(pkg.scripts.start, 'npm run build:ts && fastify start -l info dist/app.js')
130130
t.equal(pkg.scripts['build:ts'], 'tsc')
131-
t.equal(pkg.scripts.dev, 'tsc && concurrently -k -p "[{name}]" -n "TypeScript,App" -c "yellow.bold,cyan.bold" "tsc -w" "fastify start --ignore-watch=.ts$ -w -l info -P dist/app.js"')
131+
t.equal(pkg.scripts['watch:ts'], 'tsc -w')
132+
t.equal(pkg.scripts.dev, 'npm run build:ts && concurrently -k -p "[{name}]" -n "TypeScript,App" -c "yellow.bold,cyan.bold" "npm:watch:ts" "npm:dev:start"')
133+
t.equal(pkg.scripts['dev:start'], 'fastify start --ignore-watch=.ts$ -w -l info -P dist/app.js')
132134
t.equal(pkg.dependencies['fastify-cli'], '^' + cliPkg.version)
133135
t.equal(pkg.dependencies.fastify, cliPkg.dependencies.fastify)
134136
t.equal(pkg.dependencies['fastify-plugin'], cliPkg.devDependencies['fastify-plugin'] || cliPkg.dependencies['fastify-plugin'])

0 commit comments

Comments
 (0)