forked from cerc-io/snowballtools-base
Nabarun Gogoi
c0cee2c57f
* Remove unused methods from backend utils * Set project name from repo organization and name when creating project * Rename success and project components according to routes
22 lines
580 B
TypeScript
22 lines
580 B
TypeScript
import fs from 'fs-extra';
|
|
import path from 'path';
|
|
import toml from 'toml';
|
|
import debug from 'debug';
|
|
|
|
const log = debug('snowball:utils');
|
|
|
|
export const getConfig = async <ConfigType>(
|
|
configFile: string
|
|
): Promise<ConfigType> => {
|
|
const configFilePath = path.resolve(configFile);
|
|
const fileExists = await fs.pathExists(configFilePath);
|
|
if (!fileExists) {
|
|
throw new Error(`Config file not found: ${configFilePath}`);
|
|
}
|
|
|
|
const config = toml.parse(await fs.readFile(configFilePath, 'utf8'));
|
|
log('config', JSON.stringify(config, null, 2));
|
|
|
|
return config;
|
|
};
|