Added --version support

This commit is contained in:
Jonatan Nilsson 2021-10-14 10:01:33 +00:00
parent d1c4b46cea
commit 035fb0d7d0

10
bin.mjs
View file

@ -1,5 +1,8 @@
#!/usr/bin/env node
import path from 'path'
import { fileURLToPath } from 'url'
import fs from 'fs'
import config from './lib/config.mjs'
import SPServer from './lib/spserver.mjs'
@ -17,6 +20,13 @@ if (config.get('config')) {
process.exit(0)
}
if (config.get('version')) {
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const pckg = JSON.parse(fs.readFileSync(path.resolve(path.join(__dirname, './package.json'))))
console.log(`spserver ${pckg.version}`)
process.exit(0)
}
if (displayHelp) {
console.log(`Run static server for static files, simple servers or pure MVVM projects.
Specifying either file or folder serving is required.