Preval Build Info
Pre-evaluate git info, version number, timestamp, etc at build time.
Useful if you need build information in your application but you use a predefined build system (and
don't want to eject) like Angular CLI, for example. Other common solutions require adding a file
to your repository and committing it. That's not ideal because these values change so frequently
(every commit). preval-build-info
works by reading information from your repository, but storing
the build information within the node_modules folder.
Table of Contents
Features
- 🚀 Import Git information of your repo.
- 🕑 Includes version number and build timestamp.
- 📂 No need to include extra files in your repo.
- 🎉 TypeScript types included.
Installation
npm install preval-build-info --save
Usage
When you import preval-build-info
, it contains the information for your repository. The version
is pulled from your project's package.json and all the Git information is from your repo.
import * as info from 'preval-build-info';
console.log(info.version);
console.log(info.timestamp);
console.log(info.dateTime);
console.log(info.gitHash);
console.log(info.gitHashShort);
console.log(info.gitTag);
console.log(info.gitBranch);
Build information is generated on postinstall
. If you also need to update build info manually, you
can use preval-build-info-cli
in your project's scripts. For example:
"scripts": {
"prebuild": "preval-build-info-cli",
}
Development
npm install
npm run build