npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

npm-git-properties

v1.0.0

Published

Generate repository git details

Downloads

35

Readme

npm-git-properties

Generate repository git details

Example

var gitUtil = require('npm-git-properties');

console.log(gitUtil.commitIdAbbrev());
// 18f5104

console.log(gitUtil.commitIdFull());
// 18f51041eead0e4952bfe11987504e6fdf682a0f

console.log(gitUtil.currentBranch());
// v1.0.0

To understand better, run the examples: node .\examples\example-simple.js or node run .\examples\example-complex.js

To run test cases, run the file: node .\tests\tests.js

Install

npm install npm-git-properties --save

API

var gitUtil = require('npm-git-properties');

gitUtil.currentBranch([filePath]) → String

return the result of git rev-parse --short HEAD

  • Optional param filePath can be used to find current branch of a repo outside the current working directory

gitUtil.buildHost() → String

return the result of os.hostname where commands are being executed.

gitUtil.buildVersion() → String

return the current package version of repo, return error text if not able to read/parse package.json.

gitUtil.commitIdAbbrev() → String

return the short hash of the last commit in the git repository.

gitUtil.commitIdFull() → String

return the full hash of the last commit in the git repository.

gitUtil.lastCommitMsg(short) → String

return commit message of last commit in the git repository.

  • Optional param short as Boolean can be used to find short or full commit message.

gitUtil.commitUserInfo(email) → String

return user details - email (if param is true) and username of the last commit in the git repository.

  • Optional param email as Boolean can be used to find short or full commit message.

gitUtil.dateOfLastCommit() → String

returns date of last commit in the git repository.

gitUtil.isDirty() → Boolean

return the result of git diff-index HEAD -- as Boolean value.

gitUtil.remoteUrl() → String

return the current remote URL of the git repository.

gitUtil.commitIdDescAndTags(flagDirty) → String

return the result of git describe --tag --abbrev=0 or (if flagDirty is true) git describe --tags.

gitUtil.closestTagCommitCount() → Number

return the result of git rev-list --count <tagName from commitIdDescAndTags>.

gitUtil.countOfAllCommits() → Number

return the count as Number for all commits present in the git repository.

gitUtil.gitInfoAsJson(customGitPropMap, requireObject) → String/Object

return the all git information as JSON String or JSON Object (if param requireObject is true)

  • Optional param customGitPropMap can be used to override the git information.
  • Optional param requireObject as Boolean can be used to define return type as JSON Object.

gitUtil.createGitInfoFile → Boolean

return as true if able to write git details in a file gitDetails.json, throws error if not able to write any changes.

Inspiration

  1. https://github.com/kurttheviking/git-rev-sync-js (NPM Module)
  2. https://github.com/n0mer/gradle-git-properties (Gradle Module)

License

MIT

Donations

Donate on UPI ID(India): parveensoni14891@okhdfcbank