Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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) {
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 [];
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 [];
}
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
}
}