service-core/test/runner.mjs

47 lines
906 B
JavaScript
Raw Normal View History

import fs from 'fs'
import Core from '../core/core.mjs'
import GetDB from '../core/db.mjs'
import getLog from '../core/log.mjs'
import Util from '../core/util.mjs'
const name = 'service-core-runner'
const util = new Util(import.meta.url)
const log = getLog(name)
const config = {
name: name,
testapp: {
port: 31313,
provider: 'static',
}
}
try {
fs.rmSync(util.getPathFromRoot('./db.json'))
} catch {}
GetDB(config, log, util.getPathFromRoot('./db.json')).then(async function(db) {
const core = new Core(db, util, log, function() {})
console.log(db.data)
await core.init()
console.log(db.data)
db.data.core.testapp.versions.push({
id: 'ok',
version: 'ok',
stable: 0,
installed: true,
})
await core.run()
})
.then(
function() {
log.info('core is running')
},
function(err) {
log.error(err, 'Error starting runner')
process.exit(1)
})