# babel-plugin-git-version-build **Repository Path**: mirrors_coreos/babel-plugin-git-version-build ## Basic Information - **Project Name**: babel-plugin-git-version-build - **Description**: Build files used for babel-plugin-git-version-build used in tectonic-installer Edit Add topics - **Primary Language**: Unknown - **License**: ISC - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2025-12-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # babel-plugin-git-version Expose the current commit's hash and the name of "nearest" tag as constants in your code. Useful to quickly find out what version of your application is deployed. ## Installation ```sh npm install --save-dev babel-plugin-git-version ``` Also make sure that `git` is in your `$PATH`. ## Usage Add it to your `.babelrc` configuration ```json { "plugins": [ "git-version" ] } ``` After that the constants `GIT_COMMIT`, `GIT_TAG` and `GIT_RELEASE_TAG` can be used in your code. They will be replaced by the commit hash of HEAD, the name of the "nearest" tag (or "unknown" if those values can't be parsed) and the tag associated with the commit if any. ```js console.log(`Version: ${GIT_TAG} (${GIT_COMMIT} ${GIT_RELEASE_TAG})`); ``` To avoid [eslint](https://github.com/eslint/eslint) warnings just add this to your config ```json "globals": { "GIT_COMMIT": false, "GIT_TAG": false, }, ``` You may customize the plugin to your liking ```json "plugins": [ [ "git-version", { "commitDefaultValue": "unknown_commit", "tagDefaultValue": "unknown_tag", "commitConstantName": "COMMIT", "tagConstantName": "TAG", "showDirty": true, "commitLength": 7, "tagCommitLength": 7 } ] ] ``` The defaults are ```js const DEFAULT_OPTIONS = { commitDefaultValue: "unknown", tagDefaultValue: "unknown", commitConstantName: "GIT_COMMIT", tagConstantName: "GIT_TAG", releaseTagConstantName: "GIT_RELEASE_TAG", showDirty: false, commitLength: 40, tagCommitLength: 0, }; ``` ## License See [LICENSE](LICENSE)