Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function fromPackage(packagePath/*: string */)/*: ?Addon */ {
var pkg = path.join(packagePath, 'package.json');
if (fs.existsSync(pkg)) {
// $DisableFlow: flow wants string require :(
var content = require(pkg);
var keywords = content.keywords || [];
if (keywords.indexOf(ADDON_KEYWORD) > -1) {
return {
path: packagePath,
pkg: content
};
}
} else {
logger.debug('no package.json found at ' + packagePath);
}
}
fromPackage(packagePath: string): Addon | undefined {
// load packagejson if exists
const pkg = path.join(packagePath, 'package.json');
if (fs.existsSync(pkg)) {
const packageJson = require(pkg);
const keywords = packageJson.keywords || [];
if (keywords.indexOf(this.ADDON_KEYWORD) > -1) {
return {
path: packagePath,
pkg: packageJson,
hooks: {}
};
}
} else {
addonLoaderLogger.debug('no package.json found at ' + packagePath);
}
}