prebump script with informational output causes version bump failure
See original GitHub issueI have an existing project I’m interested in using with standard-version. The catch is that it has a preversion script which runs JSDoc and commits updated API documentation before release; after going through the standard-version docs, I thought the prebump hook seemed analogous and made the appropriate changes. A dry run showed a proper changelog and the expected bump from 4.4.0 to 4.5.0. However, actually cutting a release did this instead:
✔ Running lifecycle script "prebump"
ℹ - execute command: "sh build/apidocs.sh"
✔ bumping version in package.json from 4.4.0 to null
✔ bumping version in package-lock.json from 4.4.0 to null
It then failed at the tagging step because v4.4.0 already exists. Looking at the code it appears that any output in the prebump script is parsed as a version number, meaning that my original assumption was incorrect and preversion does not map to prebump.
I think at minimum the docs could be clearer about this: the example prebump script echoes a version number, but the language “returns a version #” is a bit unclear in the context of a script and there’s nothing indicating that all of stdout is being parsed. I’m actually interested in my script’s output so I don’t want to pipe everything to /dev/null, and parsing just the last line in prebump seems feasible but kludgey; I think what’s called for here is a separate lifecycle event (prerelease maybe?) which would be an actual analogue to preversion and run before prebump.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)

Top Related StackOverflow Question
Thanks @dmfay 😃
All good – I released version 4.8.3 with standard-version and the script fired as expected.