1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-03 21:10:05 +00:00

chore: verify executable paths

This commit is contained in:
2022-06-17 18:12:03 +05:00
parent 158acf1f97
commit ab222cbaab
7 changed files with 59 additions and 6 deletions

View File

@@ -53,6 +53,8 @@ export const verifyEnvVariables = (): ReturnCode => {
errors.push(...verifyRUN_TIMES())
errors.push(...verifyExecutablePaths())
if (errors.length) {
process.logger?.error(
`Invalid environment variable(s) provided: \n${errors.join('\n')}`
@@ -231,6 +233,25 @@ const verifyRUN_TIMES = (): string[] => {
return errors
}
const verifyExecutablePaths = () => {
const errors: string[] = []
const { RUN_TIMES, SAS_PATH, NODE_PATH, MODE } = process.env
if (MODE === ModeType.Server) {
const runTimes = RUN_TIMES?.split(',')
if (runTimes?.includes(RunTimeType.SAS) && !SAS_PATH) {
errors.push(`- SAS_PATH is required for ${RunTimeType.SAS} run time`)
}
if (runTimes?.includes(RunTimeType.JS) && !NODE_PATH) {
errors.push(`- NODE_PATH is required for ${RunTimeType.JS} run time`)
}
}
return errors
}
const DEFAULTS = {
MODE: ModeType.Desktop,
PROTOCOL: ProtocolType.HTTP,