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

repoinf

v0.1.2

Published

Library for getting basic information about a Git repository for versioning purposes

Downloads

9

Readme

MIT license npm version dependencies: 0

repoinf

Library for getting basic information about a Git repository for versioning purposes.

Usage

This library is available via npm:

npm i --save repoinf

Two functions are available: getRepoInfo(), which returns information about a repository, and getPlatformInfo(), which returns some basic information about the system. Both return a Promise that resolves to an object.

To use getRepoInfo(), the git command line utility needs to be available.

Reference

Function:

getRepoInfo(repoRoot[, isContainer, gitCmd])

Parameters:

  • repoRoot String
    Path to the repository to return information for.
  • isContainer Boolean: true
    Whether the repoRoot path contains the .git directory (as opposed to being the .git directory).
  • gitCmd String: "git"
    Name of or path to the Git executable, if it's not "git".

Returns:

  • isRepo Boolean
    Whether the given path is a valid repository. If not, only isRepo and hasCommits will be returned, both false.
  • hasCommits Boolean
    Whether the repository has any commits. Without commits, only the branch name can be determined and all other data is empty.
  • branch String
    Name of the currently active branch.
  • hash String
    Short 7-character hash.
  • hashFull String
    Full 40-character hash.
  • lastCommit Date
    Date of the last commit.
  • commits Number
    Number of commits on this branch.
  • version String
    Formatted string representing the repository's state, e.g. "main-423 [97a65b1]".
  • versionDashed String
    Formatted string separated only by dashes, e.g. "main-423-97a65b1".

Example:

const data = await getRepoInfo(`/path/to/project`) // path containing a .git directory
console.log(data)
// {
//   isRepo: true,
//   hasCommits: true,
//   branch: 'main',
//   hash: '97a65b1',
//   hashFull: '97a65b155b21b334975736d70d5eb20e58003cb1',
//   commits: 423,
//   lastCommit: 2021-11-14T14:11:53.000Z,
//   versionDashed: 'main-423-97a65b1',
//   version: 'main-423 [97a65b1]'
// }

Function:

getPlatformInfo()

Parameters:

  • (None.)

Returns:

  • version String
    Full string identifying the kernel version.
  • uptime Number
    Number of seconds that the system has been up.
  • platform String
    OS platform name (aix, darwin, freebsd, linux, openbsd, sunos, or win32).
  • type String
    OS name (Linux, Darwin or Windows_NT).
  • release String
    OS version.
  • hostname String
    System hostname.
  • arch String
    CPU architecture for which Node was compiled.
  • bootTime Date
    Date object based on the current time and uptime.

Example:

const data = await getPlatformInfo()
console.log(data)
// {
//   version: 'Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64',
//   uptime: 23457,
//   platform: 'darwin',
//   type: 'Darwin',
//   release: '18.7.0',
//   hostname: 'Vesuvius.local',
//   arch: 'x64',
//   bootTime: 2021-12-10T10:52:15.000Z
// }

License

© MIT license.