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

current-git-branch

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

current-git-branch - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

15

build.js

@@ -20,12 +20,15 @@ 'use strict';

var cwd = process.cwd();
var defaultOptions = {
altPath: cwd,
branchOptions: null
};
var isGitAdded = function isGitAdded() {
var altPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : cwd;
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultOptions;
var stdout = void 0;
if (!(0, _isGitRepository2.default)(altPath)) {
if (!(0, _isGitRepository2.default)(options.altPath)) {
return false;
}
var branchOptions = options.branchOptions && Array.isArray(options.branchOptions) ? options.branchOptions.join(' ') : options.branchOptions || '';
try {

@@ -35,5 +38,5 @@ var cmd = '';

if ((0, _os.platform)() === 'win32') {
cmd = 'pushd ' + altPath + ' & git branch | findstr \\*';
cmd = 'pushd ' + (options.altPath || cwd) + ' & git branch ' + branchOptions + ' | findstr \\*';
} else {
cmd = '(cd ' + altPath + ' ; git branch | grep \\*)';
cmd = '(cd ' + (options.altPath || cwd) + ' ; git branch ' + branchOptions + ' | grep \\*)';
}

@@ -40,0 +43,0 @@

@@ -0,1 +1,11 @@

1.1.0 - October, 16 2018
* 164bdb9 Chore: drop support for Node v4 (#2) (Jan Peer Stöcklmair)
* 7d6bddc Ability to pass options to `git-branch` command (#1) (Ryan Stimmler)
* 5a2b4ea 1.0.1 (JPeer264)
* fee095b Test: update fixtures (JPeer264)
* 190593d 1.0.1 (JPeer264)
* f4aba3c Feat: add test folder (JPeer264)
* b014237 Feat: remove test folder (JPeer264)
1.0.1 - December, 18 2017

@@ -2,0 +12,0 @@

2

package.json
{
"name": "current-git-branch",
"version": "1.0.1",
"version": "1.1.0",
"description": "A tool to check if files are added in a git repository",

@@ -5,0 +5,0 @@ "main": "build.js",

@@ -29,3 +29,4 @@ # current-git-branch

branchName(); // false or branch name of process.cwd()
branchName('any/git/repo'); // false or branch name of the directory 'any/git/repo'
branchName({ altPath: 'any/git/repo' }); // false or branch name of the directory 'any/git/repo'
branchName({ altPath: 'any/git/repo', branchOptions: [ "--no-color" ] }); // alternatively, you may pass git-branch command options, either as a string or an array
```

@@ -32,0 +33,0 @@

@@ -24,11 +24,11 @@ import fs from 'fs';

test('check if the given directory is the branch master', (t) => {
t.is(branchName(path.join(fixtures, 'master')), 'master');
t.is(branchName({ altPath: path.join(fixtures, 'master'), branchOptions: '--no-color' }), 'master');
});
test('check if the given directory is the branch feat/test', (t) => {
t.is(branchName(path.join(fixtures, 'feat_test')), 'feat_test');
t.is(branchName({ altPath: path.join(fixtures, 'feat_test'), branchOptions: '--no-color' }), 'feat_test');
});
test('check the branch name of the home dir', (t) => {
t.false(branchName(homedir()));
t.false(branchName({ altPath: homedir(), branchOptions: '--no-color' }));
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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