1.0.0 • Published 4 years ago

judgy-git-server-listen v1.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

judgy-git-server-listen

Get the current git branch name using Node.js and create a wrapper around the server listen instance to be judgy when coding.

Install

npm install judgy-git-server-listen --save

Usage

const { getCurrentBranchName } = require("judgy-git-server-listen");

getCurrentBranchName(); // branch name or false
const { judgyServerListen } = require("judgy-git-server-listen");

server.listen(PORT, () => {
  console.log(`Listening on port ${PORT} in ${ENV} mode.`);
});

judgyServerListen(server, PORT, () => {
  console.log(`Listening on port ${PORT} in ${ENV} mode.`);
});

API

getCurrentBranchName( path );

Returns branch name or false

Props

path

Type: string

Default: process.cwd()

Required: false

The path which you want to get it's git repository's branch name.

Actually you don't need to pass anything, just call the function anywhere inside your git repository.

CHANGE LOG

v2.0.x no longer requires you to pass the root path which you initialized your git repository, it will automatically find the branch name if it exists (git initialized).