Skip to content

Commit c1db755

Browse files
committed
fix: allow type to be omitted when semver is passed
1 parent cd18c91 commit c1db755

5 files changed

Lines changed: 29 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Just ask for help:
5050
npx react-native bump-version --help
5151

5252
Options:
53-
--type [major|minor|patch] SemVer release type, optional if --skip-semver-for all is passed
53+
--type [major|minor|patch] SemVer release type, optional if --skip-semver-for all is passed, ignored (and optional) when --semver is passed
5454
--skip-semver-for [android|ios|all] Skips bump SemVer for specified platform
5555
--skip-code-for [android|ios|all] Skips bump version codes for specified platform
5656
--semver Pass release version if known. Overwrites calculated SemVer. Optional.

react-native.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ module.exports = {
77
func: (_, config, args) => {
88
const result = versioner(config, args);
99

10-
if(result) {
10+
if (result) {
1111
result.run();
1212
}
1313
},
1414
options: [
1515
{
1616
name: "--type [major|minor|patch]",
17-
description: "SemVer release type, optional if --skip-semver-for all is passed, ignored (and optional) when --semver is passed",
17+
description:
18+
"SemVer release type, optional if --skip-semver-for all is passed, ignored (and optional) when --semver is passed",
1819
},
1920
{
2021
name: "--semver [String]",

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ class ProjectFilesManager {
302302
}
303303

304304
if (!skipSemVerFor.includes("all")) {
305-
if (!type) {
306-
throw new Error("SemVer type not specified");
305+
if (!type && !semver) {
306+
throw new Error("bump type and semver value not specified");
307307
}
308308

309309
this.syncSemver(next);

tests/__snapshots__/android.test.js.snap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ Object {
1616
}
1717
`;
1818

19+
exports[`direct set semver string and ignores non defined type 1`] = `
20+
"android {
21+
defaultConfig {
22+
versionCode 2
23+
versionName \\"1.1.2\\"
24+
}
25+
}
26+
"
27+
`;
28+
29+
exports[`direct set semver string and ignores non defined type 2`] = `
30+
Object {
31+
"version": "1.1.2",
32+
}
33+
`;
34+
1935
exports[`preserve quotes style 1`] = `
2036
"android {
2137
defaultConfig {

tests/android.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,10 @@ test("direct set semver string", () => {
4747
expect(manager.buildGradle.content).toMatchSnapshot();
4848
expect(manager.packageJSON.content).toMatchSnapshot();
4949
});
50+
51+
test("direct set semver string and ignores non defined type", () => {
52+
const manager = makeDefaultManager({ semver: "1.1.2", type: null }).dryRun();
53+
54+
expect(manager.buildGradle.content).toMatchSnapshot();
55+
expect(manager.packageJSON.content).toMatchSnapshot();
56+
});

0 commit comments

Comments
 (0)