Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mockery.registerMock('deps-object', function (deps) {
var obj = deps.reduce(function (o, v) {
var tok = v.split('@')
if (tok.length === 1) tok.push('*')
o[tok[0]] = tok[1]
return o
}, {})
return Promise.resolve(obj)
})
})
function mergeExtends(config, configDir) {
if (!config.extends) {
return Promise.resolve(config);
}
var extendLookups = [].concat(config.extends);
var resultPromise = extendLookups.reduce(function(mergedConfigPromise, extendLookup) {
return mergedConfigPromise.then(function(priorMergedConfig) {
return loadExtendConfig(priorMergedConfig, configDir, extendLookup)
.then(function(extendConfig) {
return Promise.resolve(_.merge({}, priorMergedConfig, extendConfig));
});
});
}, Promise.resolve(_.omit(config, 'extends')));
return resultPromise;
}
function mergeExtends(config, configDir) {
if (!config.extends) {
return Promise.resolve(config);
}
var extendLookups = [].concat(config.extends);
var resultPromise = extendLookups.reduce(function(mergedConfigPromise, extendLookup) {
return mergedConfigPromise.then(function(priorMergedConfig) {
return loadExtendConfig(priorMergedConfig, configDir, extendLookup)
.then(function(extendConfig) {
return Promise.resolve(_.merge({}, priorMergedConfig, extendConfig));
});
});
}, Promise.resolve(_.omit(config, 'extends')));
return resultPromise;
}
return Promise.all(realFiles.map(function(file) {
var parsedConfig;
try {
parsedConfig = require(file);
parsedConfig.__source = file;
return Promise.resolve(parsedConfig);
} catch (err) {
return fsHelpers.read(file).then(function(content) {
parsedConfig = nodeEval('(' + content + ')');
parsedConfig.__source = file;
return parsedConfig;
});
}
}));
});
return Promise.resolve(_thisConfigs).then(function(cfgs) {
doSomeMagicProcedure(cfgs, cwd);
_this._root = getConfigsRootDir(cfgs);
return plugins.reduce(
function(cfgsPromise, plugin) {
return cfgsPromise.then(function(configs_) {
return Promise.all(configs_.map(function(config) {
return new Promise(function(resolve) {
plugin(config, configs_, options, resolve);
});
}));
});
},
Promise.resolve(cfgs));
});
};
return Promise.all(files.map(function (file) {
if (!force) {
safeCheck(file);
}
file = path.resolve(opts.cwd || '', file);
if (dryRun) {
return Promise.resolve(file);
}
return rimrafP(file).then(function () {
return file;
});
}));
});
.then(function(extendConfig) {
return Promise.resolve(_.merge({}, priorMergedConfig, extendConfig));
});
});
cp.once('error', reject);
cp.once('close', function (code) {
if (code > 0) {
reject(new Error('Exited with code ' + code));
return;
}
resolve(cp);
});
});
}
cp.unref();
return Promise.resolve(cp);
};