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

push-dir

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

push-dir - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

.idea/jsLibraryMappings.xml

35

index.js

@@ -8,3 +8,4 @@ var exec = require('child_process').exec;

var hash = info.hash;
var originalBranch = info.branch;
var detachedHead = info.detachedHead;
var originalBranch = detachedHead ? hash : info.branch;

@@ -38,3 +39,3 @@ var directory = opts.dir;

.then(pushDirToRemote.bind(null, remote, remoteBranch))
.then(resetBranch.bind(null, originalBranch))
.then(resetBranch.bind(null, originalBranch, detachedHead))
.then(cleanup ? deleteLocalBranch.bind(null, local) : null)

@@ -69,5 +70,6 @@ .catch(handleError);

function resetBranch(branch) {
function resetBranch(branch, detach) {
var detached = detach ? '--detach ' : '';
return execCmd(
'git checkout -f ' + branch,
'git checkout -f ' + detached + branch,
'problem resetting branch'

@@ -123,8 +125,11 @@ );

getLastCommitHash(),
getCurrentBranch()
getCurrentBranch(),
checkIfDetachedHead()
])
.then(function(info) {
info = info.map(function(s) { return s.trim(); });
return {
hash: info[0].trim(),
branch: info[1].trim()
hash: info[0],
branch: info[1],
detachedHead: info[2] === 'true'
};

@@ -141,3 +146,15 @@ });

function checkIfDetachedHead() {
return execCmd(
'CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD`;' +
'git symbolic-ref --short -q HEAD;' +
'if [ $? -eq 1 ] && [ "$CURRENT_BRANCH" = "HEAD" ];' +
'then echo "true";' +
'else echo "false";' +
'fi',
'problem checking if detached head'
);
}
/**

@@ -154,3 +171,3 @@ * Helpers

return new Promise(function(resolve, reject) {
exec(cmd, function (error, stdout, stderr) {
exec(cmd, function(error, stdout, stderr) {
error ? reject(errMessage) : resolve(stdout);

@@ -163,3 +180,3 @@ });

return new Promise(function(resolve, reject) {
exec(cmd, function (error, stdout, stderr) {
exec(cmd, function(error, stdout, stderr) {
(error || stdout.length || stderr.length) ? reject(errMessage) : resolve();

@@ -166,0 +183,0 @@ });

{
"name": "push-dir",
"version": "0.2.0",
"version": "0.2.1",
"description": "Push a directory to a remote branch",

@@ -5,0 +5,0 @@ "keywords": [],

@@ -53,3 +53,9 @@ var test = require('tape');

test('test works - cleanup detached head', function (t) {
var cmds = fixtureTestCommands('test-works-cleanup-detached-head.sh');
exec(cmds, shouldWork.bind(null, t));
t.plan(1);
});
function fixtureTestCommands(fixture) {

@@ -69,4 +75,3 @@ return commands(

'cp -r ../fixture-working ../fixture-remote',
'PUSH_DIR=$PD_ROOT/bin/push-dir.js ./' + fixture,
'cd $PD_ROOT/test'
'PUSH_DIR=$PD_ROOT/bin/push-dir.js ./' + fixture
);

@@ -73,0 +78,0 @@ }

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

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

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