How to use require-package-name - 4 common examples

To help you get started, we’ve selected a few require-package-name 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 mattdesl / ghrepo / cmd.js View on Github external
function request(opt) {
  var pkg = opt.package
  var name = argv.n || argv.name || baseName(pkg.name)
  var description = argv.d || argv.description || pkg.description || ''
  var homepage = argv.h || argv.homepage || pkg.homepage || ''

  if (!name) {
    console.error("No name in package.json")
    process.exit(1)
  }

  if (homepage && homepage.indexOf('https://github.com/') === 0)
    homepage = ''
  
  var user = opt.org
  // try to glean default username from package.json repository URL
  if (!user && pkg.repository && pkg.repository.url) {
    var urlObj = githubUrl(pkg.repository.url)
    if (urlObj) {
github depcheck / depcheck / src / special / commitizen.js View on Github external
export default function parseCommitizen(content, filePath, deps, rootDir) {
  const packageJsonPath = path.resolve(rootDir, 'package.json');
  const resolvedFilePath = path.resolve(filePath);

  if (resolvedFilePath === packageJsonPath) {
    const metadata = JSON.parse(content);

    if (
      metadata.config &&
      metadata.config.commitizen &&
      metadata.config.commitizen.path
    ) {
      const commitizenPath = metadata.config.commitizen.path;

      if (!commitizenPath.startsWith('.')) {
        return [requirePackageName(commitizenPath)];
      }

      const normalizedPath = path.normalize(commitizenPath).replace(/\\/g, '/');

      if (!normalizedPath.startsWith('node_modules')) {
        // The path is not refering to a file in another module
        return [];
      }

      const packagePath = normalizedPath.substring('node_modules/'.length);

      return [requirePackageName(packagePath)];
    }
  }

  return [];
github depcheck / depcheck / src / special / commitizen.js View on Github external
const commitizenPath = metadata.config.commitizen.path;

      if (!commitizenPath.startsWith('.')) {
        return [requirePackageName(commitizenPath)];
      }

      const normalizedPath = path.normalize(commitizenPath).replace(/\\/g, '/');

      if (!normalizedPath.startsWith('node_modules')) {
        // The path is not refering to a file in another module
        return [];
      }

      const packagePath = normalizedPath.substring('node_modules/'.length);

      return [requirePackageName(packagePath)];
    }
  }

  return [];
}
github lodash / babel-plugin-lodash / src / Package.js View on Github external
constructor(pkgPath) {
    pkgPath = _.toString(pkgPath)
    const pkgName = requirePackageName(pkgPath)

    this.base = pkgPath.replace(new RegExp(pkgName + '/?'), '')
    this.id = pkgName
    this.isLodash = _.constant(reLodash.test(this.id))
    this.path = pkgPath
  }
}

require-package-name

gets the package name for a require statement

MIT
Latest version published 10 years ago

Package Health Score

65 / 100
Full package analysis

Popular require-package-name functions