2019-10-11 18:14:23 +02:00
|
|
|
const { resolve, join } = require("path");
|
|
|
|
const { cwd } = require("process");
|
|
|
|
const buildAppContext = require("@budibase/server/initialise/buildAppContext");
|
|
|
|
|
|
|
|
module.exports.serverFileName = relativePath =>
|
|
|
|
resolve(__dirname,
|
|
|
|
"..",
|
|
|
|
"node_modules",
|
|
|
|
"@budibase",
|
|
|
|
"server",
|
|
|
|
relativePath);
|
|
|
|
|
2019-10-11 19:44:55 +02:00
|
|
|
module.exports.getAppContext = async ({configName, masterIsCreated}) => {
|
2019-10-11 18:14:23 +02:00
|
|
|
|
|
|
|
if(configName) {
|
|
|
|
if(!configName.endsWith(".js")) {
|
|
|
|
configName = `config.${configName}.js`;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
configName = "config.js";
|
|
|
|
}
|
|
|
|
|
2019-11-07 22:46:47 +01:00
|
|
|
const config = require(resolve(cwd(), configName))();
|
2019-10-11 19:44:55 +02:00
|
|
|
return await buildAppContext(config, masterIsCreated);
|
2019-10-11 18:14:23 +02:00
|
|
|
}
|