budibase/packages/cli/src/common.js

28 lines
796 B
JavaScript
Raw Normal View History

2020-04-26 22:13:14 +02:00
const { resolve, join } = require("path")
const { cwd } = require("process")
2020-04-26 22:13:14 +02:00
const { homedir } = require("os")
const buildAppContext = require("@budibase/server/initialise/buildAppContext")
module.exports.serverFileName = relativePath =>
resolve(__dirname, "..", "node_modules", "@budibase", "server", relativePath)
2019-10-11 18:14:23 +02: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
}
} else {
configName = "config.js"
}
2019-10-11 18:14:23 +02:00
const config = require(resolve(cwd(), configName))()
return await buildAppContext(config, masterIsCreated)
}
2020-04-26 22:13:14 +02:00
module.exports.xPlatHomeDir = dir => {
if (dir.startsWith("~")) {
dir = join(homedir(), dir.substring(1))
}
return dir
}