Skip to content

Commit

Permalink
feat: throw error when "name" key is missing in package.json (#298)
Browse files Browse the repository at this point in the history
Co-authored-by: abdelrahman wahdan <abdelrahman.wahdan1@vodafone.com>
  • Loading branch information
abdelrahmanahmed and abdelrahman wahdan committed Jul 26, 2020
1 parent 3c5146d commit 8083cc0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const ownPkg = require('../package.json');
const getLog = require('./lib/log');

const pkg = JSON.parse(readFileSync('./package.json'));
if (pkg.name === undefined) throw new Error(`"name" key is missing from your package.json`);

require('update-notifier')({
pkg: _.defaults(ownPkg, {version: '0.0.0'}),
Expand Down
1 change: 0 additions & 1 deletion src/lib/npm.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ async function validateToken(otp, npm) {

function getRegistry(pkg, conf) {
if (pkg.publishConfig && pkg.publishConfig.registry) return pkg.publishConfig.registry;

if (pkg.name[0] !== '@') return conf.get('registry') || DEFAULT_REGISTRY;

const [scope] = pkg.name.split('/');
Expand Down

0 comments on commit 8083cc0

Please sign in to comment.