Skip to content

Commit f028c87

Browse files
committed
refactor: remove unnecessary let declaration
1 parent baf071b commit f028c87

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,13 @@ async function verifyConditions(pluginConfig, context) {
4242
}
4343

4444
async function prepare(pluginConfig, context) {
45-
let pkg;
4645
const errors = verified ? [] : verifyNpmConfig(pluginConfig);
4746

4847
setLegacyToken(context);
4948

5049
try {
5150
// Reload package.json in case a previous external step updated it
52-
pkg = await getPkg(pluginConfig, context);
51+
const pkg = await getPkg(pluginConfig, context);
5352
if (!verified && pluginConfig.npmPublish !== false && pkg.private !== true) {
5453
await verifyNpmAuth(pluginConfig, pkg, context);
5554
}

lib/get-pkg.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,19 @@ const AggregateError = require('aggregate-error');
44
const getError = require('./get-error');
55

66
module.exports = async ({pkgRoot}, {cwd}) => {
7-
const errors = [];
8-
let pkg;
9-
107
try {
11-
pkg = await readPkg({cwd: pkgRoot ? path.resolve(cwd, String(pkgRoot)) : cwd});
8+
const pkg = await readPkg({cwd: pkgRoot ? path.resolve(cwd, String(pkgRoot)) : cwd});
129

1310
if (!pkg.name) {
14-
errors.push(getError('ENOPKGNAME'));
11+
throw getError('ENOPKGNAME');
1512
}
13+
14+
return pkg;
1615
} catch (error) {
1716
if (error.code === 'ENOENT') {
18-
errors.push(getError('ENOPKG'));
17+
throw new AggregateError([getError('ENOPKG')]);
1918
} else {
20-
errors.push(error);
19+
throw new AggregateError([error]);
2120
}
2221
}
23-
24-
if (errors.length > 0) {
25-
throw new AggregateError(errors);
26-
}
27-
28-
return pkg;
2922
};

0 commit comments

Comments
 (0)