Skip to content

Commit 8083cc0

Browse files
abdelrahmanahmedabdelrahman wahdan
andauthored
feat: throw error when "name" key is missing in package.json (#298)
Co-authored-by: abdelrahman wahdan <[email protected]>
1 parent 3c5146d commit 8083cc0

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const ownPkg = require('../package.json');
1010
const getLog = require('./lib/log');
1111

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

1415
require('update-notifier')({
1516
pkg: _.defaults(ownPkg, {version: '0.0.0'}),

src/lib/npm.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ async function validateToken(otp, npm) {
5757

5858
function getRegistry(pkg, conf) {
5959
if (pkg.publishConfig && pkg.publishConfig.registry) return pkg.publishConfig.registry;
60-
6160
if (pkg.name[0] !== '@') return conf.get('registry') || DEFAULT_REGISTRY;
6261

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

0 commit comments

Comments
 (0)