Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function read(pmodule, dir) {
var packageJson = pkginfo.read(pmodule, dir);
var pkgJsonFile = packageJson.dir; // misleading name from pkginfo library
var pkgJsonDir = path.dirname(pkgJsonFile);
var profile = _.get(packageJson['package'], 'jest-webpack-alias.profile');
var configFile = _.get(packageJson['package'], 'jest-webpack-alias.configFile', 'webpack.config.js');
var webpackFile = path.join(pkgJsonDir, configFile);
var webpackSettings = extractES6DefaultExportsObject(require(webpackFile));
if (profile) {
if (!_.isArray(webpackSettings)) {
throw new Error(genProfileError(profile, webpackFile + ' does not export an array'));
}
webpackSettings = _.find(webpackSettings, ['name', profile]);
if (!webpackSettings) {
throw new Error(genProfileError(profile, webpackFile + ' does not contain this profile'));
}