Skip to content

Commit

Permalink
add safe findGitRoot() helper for therealklanni#39
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Hoyer committed Aug 3, 2016
1 parent 38a2451 commit 9ec15f9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ var hooks = [
'update'
];

function findGitRoot() {
var gitRevParseTopLevel = exec('git rev-parse --show-toplevel');
if (gitRevParseTopLevel.code !== 0) {
console.error('guppy-cli needs a git repository to work with.');
return exit(1);
}

return gitRevParseTopLevel.output.slice(0, -1);
}

function install(hook, dest, cb) {
cb = cb || dest;

Expand Down Expand Up @@ -74,5 +84,6 @@ function installAll(dest, cb) {
);
}

module.exports.findGitRoot = findGitRoot;
module.exports.install = install;
module.exports.installAll = installAll;

0 comments on commit 9ec15f9

Please sign in to comment.