I am using a package called babel-plugin-inline-package-json to pull out my version number during my build step. Currently using semantic-release the package version is always 0.0.0 instead of the correct version number. I setup semantic-release to trigger a build using the npm preversion command. I was under the impression that by the time semantic-release triggered preversion it would already have the new version inserted into the package.json, but I keep getting 0.0.0 instead. What would be the correct way to pull out the version number so I can get it during my build step?
getting version during preversion step
824 Views Asked by Mike F At
1
semantic-release doesn't trigger the npm
preversiondirectly, it runsnpm versionthennpm publish. The npm hook scripts (preversion,postversion,prepack,postpack,prepublish,prepublishOnly,postpublish,prepare) are triggered bynpmitself.As suggested by it's name the hook
preversionrun just before the version is updated. You need to use thepostversionhook which run after the version is updated.For more details see: How can I use a npm build script that requires the package.json’s version ?