New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

can-npm-publish

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-npm-publish - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

4

bin/cmd.js

@@ -33,3 +33,5 @@ #!/usr/bin/env node

canNpmPublish(cli.input[0])
canNpmPublish(cli.input[0], {
verbose: cli.flags.verbose
})
.then(() => {

@@ -36,0 +38,0 @@ process.exit(0);

@@ -8,15 +8,22 @@ // MIT © 2018 azu

* Return rejected promise if the package name is invalid
* @param packagePath
* @param {string} packagePath
* @param {{verbose:boolean}} options
* @returns {Promise}
*/
const checkPkgName = packagePath => {
const checkPkgName = (packagePath, options) => {
return readPkg(packagePath).then(pkg => {
const name = pkg["name"];
const result = validatePkgName(name);
if (!result.validForNewPackages) {
// Treat Legacy Names as valid
// https://github.com/npm/validate-npm-package-name#legacy-names
// https://github.com/azu/can-npm-publish/issues/8
const isInvalidNamingInNewRule = !result.validForNewPackages;
if (isInvalidNamingInNewRule) {
if (Array.isArray(result.errors)) {
return Promise.reject(new Error(result.errors.join("\n")));
} else {
return Promise.reject(new Error(JSON.stringify(result)));
}
// warning is ignored by default
if (options.verbose && result.warnings) {
console.log(result.warnings.join("\n"));
}
}

@@ -28,3 +35,3 @@ });

* Return rejected promise if the package is not `private:true`
* @param packagePath
* @param {string} packagePath
* @returns {Promise}

@@ -93,5 +100,15 @@ */

};
const canNpmPublish = packagePath => {
return Promise.all([checkPkgName(packagePath), checkAlreadyPublish(packagePath), checkPrivateField(packagePath)]);
/**
*
* @param {string} packagePath
* @param {{verbose : boolean}} options
* @returns {Promise<[any]>}
*/
const canNpmPublish = (packagePath, options = { verbose: false }) => {
return Promise.all([
checkPkgName(packagePath, options),
checkAlreadyPublish(packagePath),
checkPrivateField(packagePath)
]);
};
module.exports.canNpmPublish = canNpmPublish;
{
"name": "can-npm-publish",
"version": "1.2.1",
"version": "1.3.0",
"description": "A command line tool that check to see if `npm publish` is possible.",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc