2020-02-25 16:21:23 +01:00
|
|
|
const { resolve } = require("path")
|
2020-02-03 10:24:25 +01:00
|
|
|
const { cwd } = require("process")
|
|
|
|
const buildAppContext = require("@budibase/server/initialise/buildAppContext")
|
2019-10-11 18:14:23 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
module.exports.serverFileName = relativePath =>
|
|
|
|
resolve(__dirname, "..", "node_modules", "@budibase", "server", relativePath)
|
2019-10-11 18:14:23 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
module.exports.getAppContext = async ({ configName, masterIsCreated }) => {
|
|
|
|
if (configName) {
|
|
|
|
if (!configName.endsWith(".js")) {
|
|
|
|
configName = `config.${configName}.js`
|
2019-10-11 18:14:23 +02:00
|
|
|
}
|
2020-02-03 10:24:25 +01:00
|
|
|
} else {
|
|
|
|
configName = "config.js"
|
|
|
|
}
|
2019-10-11 18:14:23 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
const config = require(resolve(cwd(), configName))()
|
|
|
|
return await buildAppContext(config, masterIsCreated)
|
|
|
|
}
|