Comparing version 0.2.1 to 0.2.2
40
index.js
@@ -8,3 +8,3 @@ var exec = require('child_process').exec; | ||
var hash = info.hash; | ||
var detachedHead = info.detachedHead; | ||
var detachedHead = info.branch === ''; | ||
var originalBranch = detachedHead ? hash : info.branch; | ||
@@ -62,7 +62,18 @@ | ||
/** | ||
* Returns name of current branch or empty string if detached HEAD | ||
* @return {string} - name of current branch | ||
*/ | ||
function getCurrentBranch() { | ||
return execCmd( | ||
'git rev-parse --abbrev-ref HEAD', | ||
'problem getting current branch' | ||
); | ||
return Promise.resolve() | ||
.then(execCmd.bind(null, | ||
'git symbolic-ref HEAD -q', | ||
'problem getting current branch' | ||
)) | ||
.catch(function() { | ||
return ''; | ||
}) | ||
.then(function(result) { | ||
return result.replace(new RegExp('^refs\/heads\/'), ''); | ||
}); | ||
} | ||
@@ -124,4 +135,3 @@ | ||
getLastCommitHash(), | ||
getCurrentBranch(), | ||
checkIfDetachedHead() | ||
getCurrentBranch() | ||
]) | ||
@@ -132,4 +142,3 @@ .then(function(info) { | ||
hash: info[0], | ||
branch: info[1], | ||
detachedHead: info[2] === 'true' | ||
branch: info[1] | ||
}; | ||
@@ -146,15 +155,2 @@ }); | ||
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' | ||
); | ||
} | ||
/** | ||
@@ -161,0 +157,0 @@ * Helpers |
{ | ||
"name": "push-dir", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Push a directory to a remote branch", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
# push-dir | ||
[![Version][version-badge]][version-href] | ||
[![Build status][build-badge]][build-href] | ||
Push a directory to a remote branch | ||
Push the contents of a directory to a remote branch | ||
* No messing around with `.gitignore` (no need to commit the directory) | ||
* Perfect for pushing a `dist`/`build` directory to `gh-pages` | ||
## install | ||
``` | ||
npm install push-dir | ||
``` | ||
## example | ||
``` | ||
push-dir --dir build --branch gh-pages | ||
push-dir --dir=build --branch=gh-pages | ||
``` | ||
@@ -28,2 +38,5 @@ | ||
--remote | ||
The name of the remote to push to (defaults to origin) | ||
--cleanup | ||
@@ -45,3 +58,7 @@ whether to delete the local branch after creating | ||
[build-badge]: https://travis-ci.org/L33T-KR3W/push-dir.svg | ||
[version-badge]: https://img.shields.io/npm/v/push-dir.svg | ||
[version-href]: https://www.npmjs.com/package/push-dir | ||
[build-badge]: https://travis-ci.org/L33T-KR3W/push-dir.svg?branch=master | ||
[build-href]: https://travis-ci.org/L33T-KR3W/push-dir |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60464
30
63
246