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

git-describeify

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git-describeify

A Browserify tranform to require Git describe information at transform time

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

git-describeify

npm version npm license Build Status

This browserify transform calls git-describe with the provided arguments on the working directory or any other directory and parses the output to individual components. On build/transform time the git-describe information will be injected so that it can be used in, for example, browser served applications which have no access to the local file system.

Installation

Available from npm:

$ npm i git-describeify

Tests are not included in the npm package — clone the git repository to run tests.

Usage

git-describeify uses the node git-describe module. During transform, require('git-describeify') is replaced with the git-describe object.

Browserify transform

Make sure to enable the transform in Browserify by either specifying it in the terminal

$ browserify -t git-describeify

or by putting it in the package.json.

{
  "browserify": {
    "transform": [
      "git-describeify"
    ]
  }
}

Require syntax

//       Require the module        the arguments passed to git-describe
require('git-describeify', argument1, argument2, argument3, ...);

// For example
const gitInfo = require('git-describeify');

// Transforms into:
const gitInfo = {
    dirty: false,
    hash: 'g3c9c15b',
    distance: 6,
    tag: 'v2.1.0-beta',
    semver: SemVer, // SemVer instance, see https://github.com/npm/node-semver
    suffix: '6-g3c9c15b',
    raw: 'v2.1.0-beta-6-g3c9c15b',
    semverString: '2.1.0-beta+6.g3c9c15b'
}

More examples

// Target working directory
const gitInfo = require('git-describeify');

// Target the directory of the calling script
// Recommended when you want to target the repo your app resides in
const gitInfo = require('git-describeify', __dirname);

// With options (see https://www.npmjs.com/package/git-describe)
const gitInfo = require('git-describeify', __dirname, {
    longSemver: true,
    dirtySemver: false
});

// Another example: working directory, use 16 character commit hash abbreviation
const gitInfo = require('git-describeify', {
    customArguments: ['--abbrev=16']
});

Example output

{
    dirty: false,
    hash: 'g3c9c15b',
    distance: 6,
    tag: 'v2.1.0-beta',
    semver: SemVer, // SemVer instance, see https://github.com/npm/node-semver
    suffix: '6-g3c9c15b',
    raw: 'v2.1.0-beta-6-g3c9c15b',
    semverString: '2.1.0-beta+6.g3c9c15b'
}

More information

See git-describe for more information about the usage of the git-describe package.

Test

Tests can be run by cloning the repository and running the following command.

$ npm install
$ npm test

Keywords

FAQs

Package last updated on 19 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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