From eeeaf1fe1253ce81ea8a1db045e9834c4d8cf1a8 Mon Sep 17 00:00:00 2001 From: Jakob Rosenberg Date: Tue, 16 Jun 2020 22:50:06 +0200 Subject: [PATCH] add silent option --- cli.js | 1 + config.js | 1 + server.js | 5 ++--- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cli.js b/cli.js index 281ec85..253fb99 100644 --- a/cli.js +++ b/cli.js @@ -14,6 +14,7 @@ program .option('-s, --serve-ssr', 'serve SSR', defaults.serveSsr) .option('-B, --spa-port [port]', 'port serving spa app', defaults.spaPort) .option('-S, --ssr-port [port]', 'port serving SSR app', defaults.ssrPort) + .option('-q, --silent', 'port serving SSR app', defaults.silent) .action(_options => { const options = _options.opts() diff --git a/config.js b/config.js index 63f1556..2292692 100644 --- a/config.js +++ b/config.js @@ -7,6 +7,7 @@ const defaults = { ssrPort: "5005", serveSpa: false, serveSsr: false, + silent: false, } module.exports.defaults = defaults \ No newline at end of file diff --git a/server.js b/server.js index 1b133fa..1e5f831 100644 --- a/server.js +++ b/server.js @@ -9,7 +9,6 @@ const { defaults } = require('./config') * @param {Partial} _options */ module.exports.spassr = function (_options) { - const options = { ...defaults, ..._options } const { spaPort, ssrPort, serveSpa, serveSsr } = options @@ -28,13 +27,13 @@ module.exports.spassr = function (_options) { * @param { Config } options */ function startServer(options) { - const { distDir, host, port, mode } = options + const { distDir, host, port, mode, silent } = options const app = express() const fallback = mode === 'ssr' ? sendSSRRender : sendEntryPoint app.use(express.static(distDir)) app.get('*', fallback.bind({ options })) - console.log(`[spassr] Serving ${mode} on ${host}:${port}`) + if (!silent) console.log(`[spassr] Serving ${mode} on ${host}:${port}`) app.listen(port) }