Skip to content

Commit

Permalink
add silent option
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobrosenberg committed Jun 16, 2020
1 parent ac0b8de commit eeeaf1f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const defaults = {
ssrPort: "5005",
serveSpa: false,
serveSsr: false,
silent: false,
}

module.exports.defaults = defaults
5 changes: 2 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const { defaults } = require('./config')
* @param {Partial<Config>} _options
*/
module.exports.spassr = function (_options) {

const options = { ...defaults, ..._options }
const { spaPort, ssrPort, serveSpa, serveSsr } = options

Expand All @@ -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)
}

Expand Down

0 comments on commit eeeaf1f

Please sign in to comment.