waveorb
Version:
Waveorb Javascript web app development framework
40 lines (31 loc) • 827 B
JavaScript
const path = require('path')
const repl = require('repl')
const { loader } = require(path.join(__dirname, '..', 'index.js'))
const package = require(path.join(__dirname, '..', 'package.json'))
console.log(`
Waveorb cmd v${package.version}
Usage: waveorb cmd
Docs: https://waveorb.com/doc/command-line#cmd
Built in properties:
app - app object
`)
async function start() {
// Indicate that we are running a cmd session
process.env.WAVEORB_CMD = 1
const app = await loader()
let objects
if (typeof app.hooks.cmd == 'function') {
objects = await app.hooks.cmd(app)
}
// Load db if it exists
const db = app.objects.db
// Load these objects into the cmd context
const api = {
app,
db,
...objects
}
const cmd = repl.start('ᚠ ')
Object.assign(cmd.context, api)
}
start()