wishthis/node_modules/fomantic-ui/tasks/config/user.js
2023-08-17 11:47:40 +02:00

57 lines
1.4 KiB
JavaScript

/*******************************
Set-up
*******************************/
const
// npm dependencies
extend = require('extend'),
fs = require('fs'),
path = require('path'),
requireDotFile = require('require-dot-file'),
// semantic.json defaults
defaults = require('./defaults'),
config = require('./project/config')
;
let
// Final config object
gulpConfig = {},
// semantic.json settings
userConfig
;
/*******************************
User Config
*******************************/
try {
// looks for config file across all parent directories
userConfig = requireDotFile('semantic.json', process.cwd());
if (userConfig.valueOf() === false) {
console.error('No semantic.json config found');
}
} catch (error) {
if (error.code === 'MODULE_NOT_FOUND') {
console.error('require-dot-file module not found');
}
}
// extend user config with defaults
gulpConfig = !userConfig
? extend(true, {}, defaults)
: extend(false, {}, defaults, userConfig);
/*******************************
Add Derived Values
*******************************/
// adds calculated values
config.addDerivedValues(gulpConfig);
/*******************************
Export
*******************************/
module.exports = gulpConfig;