{"id":22377845,"url":"https://github.com/someimportantcompany/git-variables","last_synced_at":"2026-05-08T04:43:33.104Z","repository":{"id":42577532,"uuid":"425629276","full_name":"someimportantcompany/git-variables","owner":"someimportantcompany","description":"Git variables for NodeJS processes","archived":false,"fork":false,"pushed_at":"2023-04-22T20:40:15.000Z","size":171,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T12:53:44.663Z","etag":null,"topics":["git","nodejs","variables"],"latest_commit_sha":null,"homepage":"https://npm.im/git-variables","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/someimportantcompany.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-07T22:18:01.000Z","updated_at":"2024-04-14T12:53:44.664Z","dependencies_parsed_at":"2024-12-04T22:25:55.220Z","dependency_job_id":null,"html_url":"https://github.com/someimportantcompany/git-variables","commit_stats":{"total_commits":14,"total_committers":1,"mean_commits":14.0,"dds":0.0,"last_synced_commit":"24bb17104b874a46c08635665d92adf2f11376ad"},"previous_names":["jdrydn/git-variables"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/someimportantcompany%2Fgit-variables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/someimportantcompany%2Fgit-variables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/someimportantcompany%2Fgit-variables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/someimportantcompany%2Fgit-variables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/someimportantcompany","download_url":"https://codeload.github.com/someimportantcompany/git-variables/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245709319,"owners_count":20659693,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","nodejs","variables"],"created_at":"2024-12-04T22:15:45.167Z","updated_at":"2026-05-08T04:43:28.069Z","avatar_url":"https://github.com/someimportantcompany.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NPM](https://badge.fury.io/js/git-variables.svg)](https://npm.im/git-variables)\n[![CI](https://github.com/someimportantcompany/git-variables/workflows/Test/badge.svg?branch=master)](https://github.com/someimportantcompany/git-variables/actions?query=branch%3Amaster)\n[![Coverage](https://coveralls.io/repos/github/someimportantcompany/git-variables/badge.svg)](https://coveralls.io/github/someimportantcompany/git-variables)\n\nStatic constants fetched from `git` for your Node processes.\n\n```js\nconst { GIT_BRANCH, GIT_COMMIT } = require('git-variables');\n```\n\nExecutes synchronously on startup to reduce impact \u0026 be ready to go immediately. Use in internal build tools or user-facing applications.\n\n## Installation\n\n```\n$ npm install git-variables\n```\n\n- **Requires `git`** to be installed.\n- Must be run within a repository - suitable for monorepos too.\n\n## API\n\nVariable | Command | Example\n---- | ---- | ----\n`GIT_DESCRIBE` | `git describe --always` | `1089e4f`\n`GIT_DESCRIBE_LIGHT` | `git describe --always --tags` | `1089e4f`\n`GIT_COMMIT` | `git rev-parse --short HEAD` | `1089e4f`\n`GIT_SHA1` | `git rev-parse HEAD` | `1089e4fc62e43d7fc4a7323aaa3d09cd6cccc468`\n`GIT_BRANCH` | `git rev-parse --abbrev-ref HEAD` | `master`\n`GIT_MESSAGE` | `git log -1 --pretty=%B` | `Initial commit!\\nThis project will change the world!`\n`GIT_MESSAGE_SUBJECT` | `git log -1 --pretty=%s` | `Initial commit!`\n`GIT_MESSAGE_BODY` | `git log -1 --pretty=%b` | `This project will change the world!`\n`GIT_USER` | `git config user.name` | `jdrydn`\n`GIT_EMAIL` | `git config user.email` | `jdrydn@github.io`\n`GIT_IS_DIRTY` | `git diff --stat` | `false`\n`GIT_REPOSITORY` | `git rev-parse --show-toplevel` | `git-variables`\n\n### Examples\n\n#### AWS-CDK\n\nReference git variables in your CDK stack definition:\n\n```js\nconst lambdaNode = require('@aws-cdk/aws-lambda-nodejs');\nconst { GIT_SHA1 } = require('git-variables');\n\nnew lambdaNode.NodejsFunction(this, 'LambdaFunction', {\n  entry: './script.js',\n  handler: 'handler',\n  runtime: lambdaNode.Runtime.NODEJS_12_X,\n  memorySize: 1024,\n  timeout: cdk.Duration.seconds(300),\n  environment: {\n    COMMIT_SHA1: GIT_SHA1,\n    NODE_ENV: process.env.NODE_ENV || 'development',\n  },\n});\n```\n\n#### Serverless Framework\n\nReference git variables in your `serverless.yml` file:\n\n```yml\nservice: example-service\nprovider: aws\n\nfunctions:\n  example-function:\n    handler: script.handler\n    environment:\n      COMMIT_SHA1: ${file(./node_modules/git-variables):GIT_SHA1}\n```\n\n#### Your Application\n\nTypically, variables from `git` would be part of a build process \u0026 passed to your application as build arguments or environment variables. But there's nothing stopping you directly using this in your application:\n\n```js\n// server.js\nconst express = require('express');\nconst { GIT_COMMIT } = require('git-variables');\n\nconst app = express();\n\napp.get('/status', (req, res) =\u003e {\n  res.status(200).send(GIT_COMMIT);\n});\n\napp.listen(3000);\n```\n\nWhen deploying, you must remember to **keep your `.git/` folder**:\n\n```\n$ cd /var/app\n$ git clone github.com/jdrydn/example\n$ cd example/ \u0026\u0026 npm ci\n$ node ./server.js\n```\n\n## Notes\n\nAny questions or suggestions please [open an issue](https://github.com/someimportantcompany/git-variables/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomeimportantcompany%2Fgit-variables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsomeimportantcompany%2Fgit-variables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsomeimportantcompany%2Fgit-variables/lists"}