index.js
function (module) {
	const configKey = 'unjar-from-url-config';

	if (module == null) {
		return [];
	}

	var highestParent;
	if (module.parent != null) {
		highestParent = module.parent;
	} else {
		highestParent = module;
	}


	var parentFound = false;

	// iterate up to all parents, until parent is undefined => root of all
	while (!parentFound) {
		parentFound = highestParent.parent == undefined || highestParent.parent == null;
		// go to upper parent
		if (!parentFound) {
			highestParent = highestParent.parent;
		}
	}

	// get the path to project itself (where the package.json is)
	var pathToNodeModules = highestParent.paths[0].split("node_modules")[0];

	// read the package json
	var packageJson = require(pathToNodeModules + "package.json");

	var unjarFromUrlConfig;
	if (packageJson != null && packageJson[configKey] != null) {
		unjarFromUrlConfig = packageJson[configKey];
	}

	if (unjarFromUrlConfig != null) {
		// add the highest parent path (used as nodeModulesDir later) to each item
		var nodeModulesDir = highestParent.paths != null ? highestParent.paths[0] : '';
		unjarFromUrlConfig.forEach(function (item) {
			item.nodeModulesDir = nodeModulesDir
		});
	} else {
		console.warn("No config found in package.json: ", pathToNodeModules + "package.json");
		unjarFromUrlConfig = [];
	}

	return unjarFromUrlConfig;
}
function (module) {
	const configKey = 'unjar-from-url-config';

	if (module == null) {
		return [];
	}

	var highestParent;
	if (module.parent != null) {
		highestParent = module.parent;
	} else {
		highestParent = module;
	}


	var parentFound = false;

	// iterate up to all parents, until parent is undefined => root of all
	while (!parentFound) {
		parentFound = highestParent.parent == undefined || highestParent.parent == null;
		// go to upper parent
		if (!parentFound) {
			highestParent = highestParent.parent;
		}
	}

	// get the path to project itself (where the package.json is)
	var pathToNodeModules = highestParent.paths[0].split("node_modules")[0];

	// read the package json
	var packageJson = require(pathToNodeModules + "package.json");

	var unjarFromUrlConfig;
	if (packageJson != null && packageJson[configKey] != null) {
		unjarFromUrlConfig = packageJson[configKey];
	}

	if (unjarFromUrlConfig != null) {
		// add the highest parent path (used as nodeModulesDir later) to each item
		var nodeModulesDir = highestParent.paths != null ? highestParent.paths[0] : '';
		unjarFromUrlConfig.forEach(function (item) {
			item.nodeModulesDir = nodeModulesDir
		});
	} else {
		console.warn("No config found in package.json: ", pathToNodeModules + "package.json");
		unjarFromUrlConfig = [];
	}

	return unjarFromUrlConfig;
}
function ( module ) { const configKey = 'unjar-from-url-config' ; if ( module == null ) { return [ ] ; } var highestParent ; if ( module . parent != null ) { highestParent = module . parent ; } else { highestParent = module ; } var parentFound = false ; // iterate up to all parents, until parent is undefined => root of all while ( ! parentFound ) { parentFound = highestParent . parent == undefined || highestParent . parent == null ; // go to upper parent if ( ! parentFound ) { highestParent = highestParent . parent ; } } // get the path to project itself (where the package.json is) var pathToNodeModules = highestParent . paths [ 0 ] . split ( "node_modules" ) [ 0 ] ; // read the package json var packageJson = require ( pathToNodeModules + "package.json" ) ; var unjarFromUrlConfig ; if ( packageJson != null && packageJson [ configKey ] != null ) { unjarFromUrlConfig = packageJson [ configKey ] ; } if ( unjarFromUrlConfig != null ) { // add the highest parent path (used as nodeModulesDir later) to each item var nodeModulesDir = highestParent . paths != null ? highestParent . paths [ 0 ] : '' ; unjarFromUrlConfig . forEach ( function ( item ) { item . nodeModulesDir = nodeModulesDir } ) ; } else { console . warn ( "No config found in package.json: " , pathToNodeModules + "package.json" ) ; unjarFromUrlConfig = [ ] ; } return unjarFromUrlConfig ; }
Searches the unjar configuration inside the highest parent's package.json. This is typically used when this module is used inside another project
which has the configuration inside the package.json of the project itself.

Returns unjar configuration as a js object.

Example for configuration:
<pre><code>
// package.json of your project
...
unjar-config: [
{
"directory": "selenium-server-standalone",
"url": "http://selenium-release.storage.googleapis.com/2.43/selenium-server-standalone-2.43.1.jar"
},
{
// other jars
}
]
</pre></code>

@param {module} module to start searching the configuration file
Searches the unjar configuration inside the highest parent s package . json . This is typically used when this module is used inside another project which has the configuration inside the package . json of the project itself .