Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getConfig() {
const { token } = this.getOptions();
const { config: cosmi = {} } =
cosmiconfig('iopipe', {
cache: false,
sync: true,
rcExtensions: true
}).load(process.cwd()) || {};
const plugins = (cosmi.plugins || []).map(plugin => {
// plugins can be specified as strings or as arrays with 2 entries
// ["@iopipe/trace", ["@iopipe/logger", {"enabled": true}]]
// create require calls for each scenario
const pluginModule = _.isArray(plugin) ? plugin[0] : plugin;
const pluginConfig = _.isArray(plugin) ? JSON.stringify(plugin[1]) : '';
return `require('${pluginModule}')(${pluginConfig})`;
});
const inlineConfigObject = _.pickBy(
_.assign({}, cosmi, {
function createCosmiConfig() {
// We need to wrap loaders in order to access and transform file content (as string)
// Cosmiconfig has transform option but at this point config is not a string but an object
return cosmiconfig('graphql', {
loaders: {
'.js': {sync: cosmi.loadJs, async: cosmi.loadJs},
'.json': loadJson,
'.yaml': loadYaml,
'.yml': loadYaml,
noExt: loadYaml,
},
});
}
type => types[type].type === Boolean
);
// Parse args
const args = parseArgs(rawArgs || [], {
boolean: boleans,
string: Object.keys(types).filter(
type => types[type].type === String || types[type].type === Object
),
default: boleans.reduce((total, bool) => ({ ...total, [bool]: null }), {})
});
let options = {};
try {
// Load from "noderize" key in package.json, .noderizerc, or noderize.config.js
const results = cosmiconfig("noderize").searchSync();
if (results) {
const configOptions = results.config || {};
Object.keys(configOptions).forEach(configOptionKey => {
if (types[configOptionKey] !== undefined) {
const type = types[configOptionKey];
let value = configOptions[configOptionKey];
if (type.type === Array && !Array.isArray(value)) {
value = [value];
}
value = run(type.run, value, { options });
options[configOptionKey] = value;
} else {
log.warn(`Config key '${configOptionKey}' doesn't do anything.`);
}
});
function getConfig(configPath, searchPath = process.cwd(), stopDir = homedir()) {
const useCustomPath = !!configPath
const explorer = cosmiconfig('cca', { sync: true, stopDir })
try {
const searchPathAbsolute = !useCustomPath && searchPath
const configPathAbsolute = useCustomPath && path.join(process.cwd(), configPath)
// search from the root of the process if the user didnt specify a config file,
// or use the custom path if a file is passed.
const result = explorer.load(searchPathAbsolute, configPathAbsolute)
// dont throw if the explorer didnt find a configfile,
// instead use default config
const config = result ? result.config : {}
const filepath = result ? result.filepath : {}
if (!result) Logger.log('No config file detected, using defaults.')
return { ...config, filepath }
} catch (error) {
function loadExtendedConfig(config, configDir, extendLookup) {
const extendPath = getModulePath(configDir, extendLookup)
const extendDir = path.dirname(extendPath)
return cosmiconfig(null, {
configPath: extendPath,
// In case `--config` was used: do not pay attention to it again
argv: false,
}).then(result => {
// Make sure to also augment the config that we're merging in
// ... but the `ignoreFiles` option only works with the
// config that is being directly invoked, not any
// extended configs
return augmentConfig(stripIgnoreFiles(result.config), extendDir)
})
}
async function loadConfig(
cwd: string,
configPath?: string
): Promise {
const explorer = cosmiconfig('commitlint');
const explicitPath = configPath ? path.resolve(cwd, configPath) : undefined;
const explore = explicitPath ? explorer.load : explorer.search;
const searchPath = explicitPath ? explicitPath : cwd;
const local = await explore(searchPath);
if (local) {
return local;
}
return null;
}
icon: false,
native: false,
prettier: true,
prettierConfig: null,
ref: false,
replaceAttrValues: null,
svgProps: null,
svgo: true,
svgoConfig: null,
template: null,
titleProp: false,
runtimeConfig: true,
plugins: null,
}
const explorer = cosmiconfig('svgr', {
sync: true,
cache: true,
rcExtensions: true,
})
export async function resolveConfig(searchFrom, configFile) {
if (configFile == null) {
const result = await explorer.search(searchFrom)
return result ? result.config : null
}
const result = await explorer.load(configFile)
return result ? result.config : null
}
resolveConfig.sync = (searchFrom, configFile) => {
if (configFile == null) {
private async loadConfig(path: string): Promise {
try {
const { config } = await cosmic('svelte', {
packageProp: false,
}).load(path);
return { ...DEFAULT_OPTIONS, ...config };
} catch (err) {
return { ...DEFAULT_OPTIONS, preprocess: {} };
}
}
async function loadConfig(cwd, configPath) {
const explorer = cosmiconfig('commitlint');
const explicitPath = configPath ? path.resolve(cwd, configPath) : undefined;
const explore = explicitPath ? explorer.load : explorer.search;
const searchPath = explicitPath ? explicitPath : cwd;
const local = await explore(searchPath);
if (local) {
return local;
}
return {};
}