bump-regex icon indicating copy to clipboard operation
bump-regex copied to clipboard

Cannot bump a prerelease identifier containing a dot when preid is specified

Open gilly3 opened this issue 6 years ago • 1 comments

Given a version with a prerelease identifier containing a dot, such as 1.0.0-foo.bar.0, if bump() is called with preid specified, the version is unchanged:

const bump = require("bump-regex");
const bumpOpts = {
    str: 'version: "1.0.0-foo.bar.0"',
    type: "prerelease",
    preid: "foo.bar"
};
bump(bumpOpts, (err, out) => console.log(out));

Output:

{ key: 'version',
  type: 'prerelease',
  case: false,
  keys: null,
  str: 'version: "1.0.0-foo.bar.0"',
  preid: 'foo.bar',
  prev: '1.0.0-foo.bar.0',
  new: '1.0.0-foo.bar.0' }

Notice that out.prev === out.new.

I've found that if I omit the preid option, it is bumped correctly:

const bump = require("bump-regex");
const bumpOpts = {
    str: 'version: "1.0.0-foo.bar.0"',
    type: "prerelease"
};
bump(bumpOpts, (err, out) => console.log(out));

Output:

{ key: 'version',
  type: 'prerelease',
  case: false,
  keys: null,
  str: 'version: "1.0.0-foo.bar.1"',
  prev: '1.0.0-foo.bar.0',
  new: '1.0.0-foo.bar.1' }

I would expect that specifying preid would not cause the bump to fail.

gilly3 avatar Dec 12 '17 19:12 gilly3

Seems to be an issue with semver, I opened an issue to confirm

stephenlacy avatar Dec 14 '17 16:12 stephenlacy