0

I'd like to display the date of a release on my website (together with the release version e.g. 0.3.1).

Option 1

I would prefer to set the date when I bump the version:

npm version patch --> preferebly adds a data value to the package.json

Option 2

Another approach is to add the date while I build. e.g. npm run deploy:prod This approach is in particular applicable and accurate, if the latest dependencies are pulled. Though not for me, since I check in my dependencies to have no surprises when I build in production.

QUESTION

How could one add a date to the package.json in both options?

I know how to read:

declare function require(moduleName: string): any;
const { version } = require('../../package.json');
    
export const envVersion = {
  VERSION: version
};
feder
  • 1,849
  • 2
  • 25
  • 43
  • Does this answer your query? https://stackoverflow.com/a/49742615/7743705 – Dhruv Shah Jul 07 '20 at 09:07
  • @DhruvShah I think that is not Windows safe. (they use export instead of SET. Makes it harder to test). That's why I rather have it in the package.json (like the version too). Thanks though. – feder Jul 07 '20 at 09:41
  • Does your question mean that "is it valid to add a date parameter in package.json"? – Dhruv Shah Jul 07 '20 at 09:45
  • @DhruvShah No. Not valid. I want to simply do it. Preferably with npm version patch. – feder Jul 07 '20 at 11:44

0 Answers0