Skip to content

Commit eda41f0

Browse files
pvdlggr2m
authored andcommitted
fix: do not make package.json's version mandatory
1 parent e611dad commit eda41f0

File tree

3 files changed

+0
-28
lines changed

3 files changed

+0
-28
lines changed

lib/get-pkg.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ module.exports = async pkgRoot => {
1212
if (!pkg.name) {
1313
errors.push(new SemanticReleaseError('No "name" found in package.json.', 'ENOPKGNAME'));
1414
}
15-
16-
if (!pkg.version) {
17-
errors.push(new SemanticReleaseError('No "version" found in package.json.', 'ENOPKGVERSION'));
18-
}
1915
} catch (err) {
2016
if (err.code === 'ENOENT') {
2117
errors.push(new SemanticReleaseError('A package.json file is required to release on npm.', 'ENOPKG'));

test/get-pkg.test.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,6 @@ test.serial('Throw error if missing package name', async t => {
5050
t.is(error.code, 'ENOPKGNAME');
5151
});
5252

53-
test.serial('Throw error if missing package version', async t => {
54-
await outputJson('./package.json', {name: 'package'});
55-
56-
const [error] = await t.throws(getPkg());
57-
58-
t.is(error.name, 'SemanticReleaseError');
59-
t.is(error.code, 'ENOPKGVERSION');
60-
});
61-
62-
test.serial('Throw errors if missing package version and name', async t => {
63-
await outputJson('./package.json', {});
64-
65-
const errors = [...(await t.throws(getPkg()))];
66-
67-
t.is(errors[0].name, 'SemanticReleaseError');
68-
t.is(errors[0].code, 'ENOPKGNAME');
69-
t.is(errors[1].name, 'SemanticReleaseError');
70-
t.is(errors[1].code, 'ENOPKGVERSION');
71-
});
72-
7353
test.serial('Throw error if package.json is malformed', async t => {
7454
await writeFile('./package.json', "{name: 'package',}");
7555

test/integration.test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ test.serial('Throw SemanticReleaseError Array if config option are not valid in
144144
t.is(errors[2].code, 'EINVALIDPKGROOT');
145145
t.is(errors[3].name, 'SemanticReleaseError');
146146
t.is(errors[3].code, 'ENOPKGNAME');
147-
t.is(errors[4].name, 'SemanticReleaseError');
148-
t.is(errors[4].code, 'ENOPKGVERSION');
149147
});
150148

151149
test.serial('Publish the package', async t => {
@@ -257,8 +255,6 @@ test.serial('Throw SemanticReleaseError Array if config option are not valid in
257255
t.is(errors[2].code, 'EINVALIDPKGROOT');
258256
t.is(errors[3].name, 'SemanticReleaseError');
259257
t.is(errors[3].code, 'ENOPKGNAME');
260-
t.is(errors[4].name, 'SemanticReleaseError');
261-
t.is(errors[4].code, 'ENOPKGVERSION');
262258
});
263259

264260
test.serial('Verify token and set up auth only on the fist call', async t => {

0 commit comments

Comments
 (0)