How to use the mpath.name function in mpath

To help you get started, we’ve selected a few mpath 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 wobscale / EuIrcBot / node-module-manager.js View on Github external
me.getModuleName = function (mpath) {
  let m;
  const stats = fs.statSync(mpath);
  try {
    m = require(mpath).name;
    if (m) return m;
  } catch (ex) {
    /* not a warning yet. Eventually maybe */
  }
  if (stats.isDirectory()) {
    try {
      m = JSON.parse(fs.readFileSync(path.join(mpath, 'package.json'))).name;
      if (m) return m;
    } catch (ex) {
      log.warn(ex, 'invalid package.json for %s', mpath);
    }
  }
  return mpath;
};

mpath

{G,S}et object values using MongoDB-like path notation

MIT
Latest version published 3 years ago

Package Health Score

68 / 100
Full package analysis