35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { AppConfiguration } from './app-configuration';
|
|
import { logger } from './logger';
|
|
|
|
export class Config {
|
|
public static loadConfig(): AppConfiguration {
|
|
logger.info('Loading configuration');
|
|
const gitPath = Bun.env.GIT_REPO_PATH?.trim();
|
|
if (!gitPath) {
|
|
logger.error('GIT_REPO_PATH is not set');
|
|
throw new Error('GIT_REPO_PATH is not set');
|
|
}
|
|
const pathToSave = Bun.env.PATH_TO_SAVE?.trim();
|
|
if (!pathToSave) {
|
|
logger.error('PATH_TO_SAVE is not set');
|
|
throw new Error('PATH_TO_SAVE is not set');
|
|
}
|
|
const pathToSaveDocx = Bun.env.PATH_TO_SAVE_DOCX?.trim();
|
|
if (!pathToSaveDocx) {
|
|
logger.error('PATH_TO_SAVE_DOCX is not set');
|
|
throw new Error('PATH_TO_SAVE_DOCX is not set');
|
|
}
|
|
const branch = Bun.env.BRANCH_NAME?.trim();
|
|
if (!branch) {
|
|
logger.error('BRANCH_NAME is not set');
|
|
throw new Error('BRANCH_NAME is not set');
|
|
}
|
|
return new AppConfiguration({
|
|
gitPath: gitPath,
|
|
pathToSave: pathToSave || '../repo',
|
|
pathToSaveDocx: pathToSaveDocx || '../listing',
|
|
branch: branch,
|
|
});
|
|
}
|
|
}
|