21 lines
621 B
TypeScript
21 lines
621 B
TypeScript
import path from 'path'
|
|
import fs from 'fs'
|
|
import { ArgumentsCamelCase } from 'yargs'
|
|
import { ProjectRunner } from '../project'
|
|
|
|
export const prepareConfig = (argv: ArgumentsCamelCase) => {
|
|
const configArg = argv.config as string
|
|
const configPath = path.join(process.cwd(), configArg)
|
|
|
|
console.debug(`Load configuration from ${configPath}`)
|
|
|
|
if (!fs.existsSync(configPath)) {
|
|
console.error(`No config not found at ${configPath}!`)
|
|
process.exit(1)
|
|
}
|
|
|
|
console.debug('Create project runner')
|
|
const project = ProjectRunner.loadProject(configPath)
|
|
argv._project_runner = new ProjectRunner(project)
|
|
}
|