# head-hash

> Get the current commit hash.

Latest version **0.3.0** (published 2017-08-31) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install head-hash
pnpm add head-hash
yarn add head-hash
bun add head-hash
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2017-08-31 |
| First published | 2016-08-07 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Seth Holladay |
| Maintainers | sholladay |
| Keywords | git, commit, commits, rev, head, hash, version, versions, current, latest, build, builds |

## Links

- npm: https://www.npmjs.com/package/head-hash
- Repository: https://github.com/sholladay/head-hash
- Issues: https://github.com/sholladay/head-hash/issues
- npm.io page: https://npm.io/package/head-hash

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2017-08-31
- 0.2.3 — 2016-08-30
- 0.2.2 — 2016-08-10
- 0.2.1 — 2016-08-10
- 0.2.0 — 2016-08-09
- 0.1.0 — 2016-08-07

## README

# head-hash [![Build status for head-hash](https://img.shields.io/circleci/project/sholladay/head-hash/master.svg "Build Status")](https://circleci.com/gh/sholladay/head-hash "Builds")

> Get the current commit hash

## Why?

 - Useful hash for cache busting.
 - Can be used as a [build version](https://github.com/sholladay/build-version).
 - Identify code without leaking secrets.

## Install

```sh
npm install head-hash --save
```

## Usage

Get it into your program.

```js
const headHash = require('head-hash');
```

Get the hash of the current [HEAD](http://stackoverflow.com/a/2529982 "The git HEAD is the current commit.").

```js
headHash().then((hash) => {
    console.log('hash:', hash);
});
```

## API

### headHash(option)

#### option

Type: `object`

##### cwd

Type: `string`<br>
Default: `process.cwd()`

The directory who's HEAD you want to use for finding the latest commit.

##### short

Type: `boolean`<br>
Default: `false`

Whether to shorten the hash to the shortest possible unique name of at least 7 characters.

## Related

 - [branch-name](https://github.com/sholladay/branch-name) - Get the current branch name.

## Contributing

See our [contributing guidelines](https://github.com/sholladay/head-hash/blob/master/CONTRIBUTING.md "Guidelines for participating in this project") for more details.

1. [Fork it](https://github.com/sholladay/head-hash/fork).
2. Make a feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. [Submit a pull request](https://github.com/sholladay/head-hash/compare "Submit code to this project for review").

## License

[MPL-2.0](https://github.com/sholladay/head-hash/blob/master/LICENSE "License for head-hash") © [Seth Holladay](http://seth-holladay.com "Author of head-hash")

Go make something, dang it.

---
_Source: https://npm.io/package/head-hash · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
