How to use the pkg.keywords function in pkg

To help you get started, we’ve selected a few pkg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github piobyte / flamingo / src / addon / discovery.js View on Github external
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);
  }
}
github piobyte / flamingo / src / addon / loader.ts View on Github external
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);
    }
  }