exit on help message and add logs

This commit is contained in:
typicode
2023-12-27 02:58:13 +01:00
parent cfc0b33a87
commit 59d39384ff

View File

@ -48,6 +48,7 @@ Options:
-s, --static <dir> Static files directory (multiple allowed) -s, --static <dir> Static files directory (multiple allowed)
--help Show this message --help Show this message
`) `)
process.exit()
} }
if (values.version) { if (values.version) {
@ -63,12 +64,6 @@ const file = positionals[0] ?? ''
const port = parseInt(values.port ?? process.env['PORT'] ?? '3000') const port = parseInt(values.port ?? process.env['PORT'] ?? '3000')
const host = values.host ?? process.env['HOST'] ?? 'localhost' const host = values.host ?? process.env['HOST'] ?? 'localhost'
// Check file
if (file === '') {
console.log('No file specified')
process.exit(1)
}
if (!existsSync(file)) { if (!existsSync(file)) {
console.log(`File ${file} not found`) console.log(`File ${file} not found`)
process.exit(1) process.exit(1)
@ -125,5 +120,6 @@ if (process.env['NODE_ENV'] !== 'production') {
app.listen(port, () => { app.listen(port, () => {
console.log(`Started on :${port}`) console.log(`Started on :${port}`)
console.log(`Watching ${file}...`)
console.log(routes(db).join('\n')) console.log(routes(db).join('\n'))
}) })