mirror of
https://github.com/morhetz/gruvbox.git
synced 2025-11-17 07:43:38 -05:00
chore(package): re-init package with commitizen and standard-release
This commit is contained in:
52
node_modules/yargs/lib/apply-extends.js
generated
vendored
Normal file
52
node_modules/yargs/lib/apply-extends.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var assign = require('./assign')
|
||||
var YError = require('./yerror')
|
||||
|
||||
var previouslyVisitedConfigs = []
|
||||
|
||||
function checkForCircularExtends (path) {
|
||||
if (previouslyVisitedConfigs.indexOf(path) > -1) {
|
||||
throw new YError("Circular extended configurations: '" + path + "'.")
|
||||
}
|
||||
}
|
||||
|
||||
function getPathToDefaultConfig (cwd, pathToExtend) {
|
||||
return path.resolve(cwd, pathToExtend)
|
||||
}
|
||||
|
||||
function applyExtends (config, cwd) {
|
||||
var defaultConfig = {}
|
||||
|
||||
if (config.hasOwnProperty('extends')) {
|
||||
if (typeof config.extends !== 'string') return defaultConfig
|
||||
var isPath = /\.json$/.test(config.extends)
|
||||
var pathToDefault = null
|
||||
if (!isPath) {
|
||||
try {
|
||||
pathToDefault = require.resolve(config.extends)
|
||||
} catch (err) {
|
||||
// most likely this simply isn't a module.
|
||||
}
|
||||
} else {
|
||||
pathToDefault = getPathToDefaultConfig(cwd, config.extends)
|
||||
}
|
||||
// maybe the module uses key for some other reason,
|
||||
// err on side of caution.
|
||||
if (!pathToDefault && !isPath) return config
|
||||
|
||||
checkForCircularExtends(pathToDefault)
|
||||
|
||||
previouslyVisitedConfigs.push(pathToDefault)
|
||||
|
||||
defaultConfig = isPath ? JSON.parse(fs.readFileSync(pathToDefault, 'utf8')) : require(config.extends)
|
||||
delete config.extends
|
||||
defaultConfig = applyExtends(defaultConfig, path.dirname(pathToDefault))
|
||||
}
|
||||
|
||||
previouslyVisitedConfigs = []
|
||||
|
||||
return assign(defaultConfig, config)
|
||||
}
|
||||
|
||||
module.exports = applyExtends
|
||||
Reference in New Issue
Block a user