fastify-cli
Advanced tools
Comparing version 2.7.0 to 2.8.0
@@ -28,2 +28,3 @@ 'use strict' | ||
'fastify-autoload': cliPkg.devDependencies['fastify-autoload'], | ||
'fastify-sensible': cliPkg.devDependencies['fastify-sensible'], | ||
'fastify-cli': '^' + cliPkg.version | ||
@@ -57,2 +58,3 @@ }, | ||
'fastify-autoload': cliPkg.devDependencies['fastify-autoload'], | ||
'fastify-sensible': cliPkg.devDependencies['fastify-sensible'], | ||
'fastify-cli': '^' + cliPkg.version | ||
@@ -59,0 +61,0 @@ }, |
{ | ||
"name": "fastify-cli", | ||
"version": "2.7.0", | ||
"version": "2.8.0", | ||
"description": "Run a fastify route with one command!", | ||
@@ -51,2 +51,3 @@ "main": "cli.js", | ||
"chokidar": "^3.3.1", | ||
"close-with-grace": "^1.0.0", | ||
"commist": "^1.0.0", | ||
@@ -70,6 +71,7 @@ "dotenv": "^8.2.0", | ||
"@types/tap": "^14.10.1", | ||
"concurrently": "^5.1.0", | ||
"concurrently": "^6.0.0", | ||
"del-cli": "^3.0.1", | ||
"fastify-autoload": "^3.3.1", | ||
"fastify-plugin": "^3.0.0", | ||
"fastify-sensible": "^3.1.0", | ||
"fastify-tsconfig": "^1.0.1", | ||
@@ -76,0 +78,0 @@ "minimatch": "^3.0.4", |
13
start.js
@@ -11,2 +11,3 @@ #! /usr/bin/env node | ||
const isDocker = require('is-docker') | ||
const closeWithGrace = require('close-with-grace') | ||
const listenAddressDocker = '0.0.0.0' | ||
@@ -130,2 +131,14 @@ const watch = require('./lib/watch') | ||
const closeListeners = closeWithGrace({ delay: 500 }, async function ({ signal, err, manual }) { | ||
if (err) { | ||
fastify.log.error(err) | ||
} | ||
await fastify.close() | ||
}) | ||
await fastify.addHook('onClose', (instance, done) => { | ||
closeListeners.uninstall() | ||
done() | ||
}) | ||
if (opts.address) { | ||
@@ -132,0 +145,0 @@ await fastify.listen(opts.port, opts.address) |
@@ -10,2 +10,5 @@ "use strict"; | ||
// Require library to exit fastify process, gracefully (if possible) | ||
import closeWithGrace from "close-with-grace"; | ||
// Instantiate Fastify with some config | ||
@@ -19,2 +22,15 @@ const app = Fastify({ | ||
// delay is the number of milliseconds for the graceful close to finish | ||
const closeListeners = closeWithGrace({ delay: 500 }, async function ({ signal, err, manual }) { | ||
if (err) { | ||
app.log.error(err) | ||
} | ||
await app.close() | ||
}) | ||
app.addHook('onClose', async (instance, done) => { | ||
closeListeners.uninstall() | ||
done() | ||
}) | ||
// Start listening. | ||
@@ -21,0 +37,0 @@ app.listen(process.env.PORT || 3000, (err: any) => { |
@@ -9,2 +9,5 @@ 'use strict' | ||
// Require library to exit fastify process, gracefully (if possible) | ||
const closeWithGrace = require('close-with-grace') | ||
// Instantiate Fastify with some config | ||
@@ -19,2 +22,15 @@ const app = Fastify({ | ||
// delay is the number of milliseconds for the graceful close to finish | ||
const closeListeners = closeWithGrace({ delay: 500 }, async function ({ signal, err, manual }) { | ||
if (err) { | ||
app.log.error(err) | ||
} | ||
await app.close() | ||
}) | ||
app.addHook('onClose', async (instance, done) => { | ||
closeListeners.uninstall() | ||
done() | ||
}) | ||
// Start listening. | ||
@@ -21,0 +37,0 @@ app.listen(process.env.PORT || 3000, (err) => { |
@@ -107,3 +107,3 @@ 'use strict' | ||
test('should finish succesfully with typescript template', async (t) => { | ||
t.plan(21 + Object.keys(expected).length) | ||
t.plan(22 + Object.keys(expected).length) | ||
try { | ||
@@ -141,2 +141,3 @@ await generate(workdir, typescriptTemplate) | ||
t.equal(pkg.dependencies['fastify-autoload'], cliPkg.devDependencies['fastify-autoload']) | ||
t.equal(pkg.dependencies['fastify-sensible'], cliPkg.devDependencies['fastify-sensible']) | ||
t.equal(pkg.devDependencies['@types/node'], cliPkg.devDependencies['@types/node']) | ||
@@ -143,0 +144,0 @@ t.equal(pkg.devDependencies.concurrently, cliPkg.devDependencies.concurrently) |
@@ -111,3 +111,3 @@ 'use strict' | ||
test('should finish succesfully with javascript template', async (t) => { | ||
t.plan(13 + Object.keys(expected).length) | ||
t.plan(14 + Object.keys(expected).length) | ||
try { | ||
@@ -123,3 +123,3 @@ await generate(workdir, javascriptTemplate) | ||
test('--integrate option will enhance preexisting package.json and overwrite preexisting files', async (t) => { | ||
t.plan(13 + Object.keys(expected).length) | ||
t.plan(14 + Object.keys(expected).length) | ||
try { | ||
@@ -158,2 +158,3 @@ await generate(workdir, javascriptTemplate) | ||
t.equal(pkg.dependencies['fastify-autoload'], cliPkg.devDependencies['fastify-autoload']) | ||
t.equal(pkg.dependencies['fastify-sensible'], cliPkg.devDependencies['fastify-sensible']) | ||
t.equal(pkg.devDependencies.tap, cliPkg.devDependencies.tap) | ||
@@ -160,0 +161,0 @@ |
@@ -244,3 +244,3 @@ 'use strict' | ||
ifError (err) { | ||
t.equal(err.message, `ERR_AVVIO_PLUGIN_TIMEOUT: plugin did not start in time: ${path.join(__dirname, 'data', 'timeout-plugin.js')}`) | ||
t.equal(err.message, `ERR_AVVIO_PLUGIN_TIMEOUT: plugin did not start in time: ${path.join(__dirname, 'data', 'timeout-plugin.js')}. You may have forgotten to call 'done' function or to resolve a Promise`) | ||
} | ||
@@ -254,3 +254,3 @@ } | ||
} catch (err) { | ||
t.equal(err.message, `ERR_AVVIO_PLUGIN_TIMEOUT: plugin did not start in time: ${path.join(__dirname, 'data', 'timeout-plugin.js')}`) | ||
t.equal(err.message, `ERR_AVVIO_PLUGIN_TIMEOUT: plugin did not start in time: ${path.join(__dirname, 'data', 'timeout-plugin.js')}. You may have forgotten to call 'done' function or to resolve a Promise`) | ||
} | ||
@@ -257,0 +257,0 @@ }) |
132057
107
3342
19
22
+ Addedclose-with-grace@^1.0.0
+ Addedclose-with-grace@1.3.0(transitive)