Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

head-hash

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

head-hash - npm Package Compare versions

Comparing version 0.2.3 to 0.3.0

25

index.js
'use strict';
const { exec } = require('child_process');
const { promisify } = require('util');
const childProcess = require('child_process');
const headHash = (option) => {
const exec = promisify(childProcess.exec);
const headHash = async (option) => {
const config = Object.assign({}, option);
return new Promise((resolve, reject) => {
const command = [
'git rev-parse --verify',
config.short ? ' --short' : '',
' HEAD'
].join('');
exec(command, { cwd : config.cwd }, (err, stdout) => {
if (err) {
reject(err);
return;
}
resolve(stdout.trimRight());
});
});
const short = config.short ? ' --short' : '';
const command = `git rev-parse --verify${short} HEAD`;
const { stdout } = await exec(command, { cwd : config.cwd });
return stdout.trimRight();
};
module.exports = headHash;
{
"name": "head-hash",
"version": "0.2.3",
"description": "Get the current commit hash.",
"homepage": "https://github.com/sholladay/head-hash",
"main": "index.js",
"author": {
"name": "Seth Holladay",
"url": "http://seth-holladay.com",
"email": "me@seth-holladay.com"
},
"scripts": {
"test": "xo"
},
"repository": {
"type": "git",
"url": "git@github.com:sholladay/head-hash.git"
},
"bugs": {
"url": "https://github.com/sholladay/head-hash/issues",
"email": "me@seth-holladay.com"
},
"engines": {
"node": ">=6"
},
"license": "MPL-2.0",
"files": [
"index.js"
],
"devDependencies": {
"eslint-config-tidy": "^0.3.0",
"xo": "^0.16.0"
},
"keywords": [
"git",
"commit",
"commits",
"rev",
"head",
"hash",
"version",
"versions",
"current",
"latest",
"build",
"builds"
],
"xo": {
"extend": "tidy"
}
"name": "head-hash",
"version": "0.3.0",
"description": "Get the current commit hash.",
"homepage": "https://github.com/sholladay/head-hash",
"main": "index.js",
"author": {
"name": "Seth Holladay",
"url": "http://seth-holladay.com",
"email": "me@seth-holladay.com"
},
"scripts": {
"test": "xo && ava"
},
"repository": {
"type": "git",
"url": "git@github.com:sholladay/head-hash.git"
},
"bugs": {
"url": "https://github.com/sholladay/head-hash/issues",
"email": "me@seth-holladay.com"
},
"engines": {
"node": ">=8"
},
"license": "MPL-2.0",
"files": [
"index.js"
],
"devDependencies": {
"ava": "^0.22.0",
"eslint-config-tidy": "^0.5.0",
"mkdirtemp": "^1.1.0",
"xo": "^0.18.2"
},
"keywords": [
"git",
"commit",
"commits",
"rev",
"head",
"hash",
"version",
"versions",
"current",
"latest",
"build",
"builds"
],
"xo": {
"extend": "tidy"
}
}

@@ -1,4 +0,4 @@

# head-hash [![Build status for head-hash on Circle CI.](https://img.shields.io/circleci/project/sholladay/head-hash/master.svg "Circle Build Status")](https://circleci.com/gh/sholladay/head-hash "Head Hash Builds")
# 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.
> Get the current commit hash

@@ -33,5 +33,31 @@ ## Why?

## 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 "The guidelines for participating in this project.") for more details.
See our [contributing guidelines](https://github.com/sholladay/head-hash/blob/master/CONTRIBUTING.md "Guidelines for participating in this project") for more details.

@@ -42,8 +68,8 @@ 1. [Fork it](https://github.com/sholladay/head-hash/fork).

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.").
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 "The license for head-hash.") © [Seth Holladay](http://seth-holladay.com "Author of head-hash.")
[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.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc