wishthis/node_modules/fomantic-ui/tasks/config/user.js

58 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-01-13 13:00:31 +00:00
/*******************************
Set-up
*******************************/
2023-08-17 09:47:40 +00:00
const
// npm dependencies
fs = require('fs'),
path = require('path'),
extend = require('extend'),
2023-08-17 09:47:40 +00:00
requireDotFile = require('require-dot-file'),
// semantic.json defaults
defaults = require('./defaults'),
config = require('./project/config')
;
2022-01-13 13:00:31 +00:00
2023-08-17 09:47:40 +00:00
let
// Final config object
gulpConfig = {},
2022-01-13 13:00:31 +00:00
2023-08-17 09:47:40 +00:00
// semantic.json settings
userConfig
2022-01-13 13:00:31 +00:00
;
/*******************************
User Config
*******************************/
try {
2023-08-17 09:47:40 +00:00
// 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');
}
2022-01-13 13:00:31 +00:00
}
// extend user config with defaults
2023-08-17 09:47:40 +00:00
gulpConfig = !userConfig
? extend(true, {}, defaults)
: extend(false, {}, defaults, userConfig);
2022-01-13 13:00:31 +00:00
/*******************************
Add Derived Values
*******************************/
// adds calculated values
config.addDerivedValues(gulpConfig);
/*******************************
Export
*******************************/
module.exports = gulpConfig;