@deg-skeletor/core
Version:
The core engine for the Skeletor family of build tools
40 lines (31 loc) • 746 B
JavaScript
const path = require('path');
const fs = require('fs');
const defaultConfigFilepath = './skeletor.config.js';
const loadConfigFile = () => {
const configFilepath = path.resolve(process.cwd(), defaultConfigFilepath);
fs.accessSync(configFilepath);
return require(configFilepath);
};
module.exports = configManager = () => {
let config = null;
const getConfig = () => {
if(config === null) {
config = loadConfigFile();
}
return config;
};
const setConfig = cfg => {
config = cfg;
};
const getTaskConfig = taskName => {
if(config === null) {
throw new Error('No configuration specified');
}
return config.tasks.find(task => task.name === taskName);
};
return {
getConfig,
setConfig,
getTaskConfig
};
};