Skip to content

Commit

Permalink
fix therealklanni#39 replacing unsafe call of exec() with findGitRoot()
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Hoyer committed Aug 3, 2016
1 parent 9ec15f9 commit 636657d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/* global error */
'use strict';

require('shelljs/global');
var fs = require("fs");
var gup = require('../');
var yargs = require('yargs')
Expand Down Expand Up @@ -40,8 +39,7 @@ var dest;
if (argv.dest) {
dest = argv.dest;
} else {
var topLevel = exec('git rev-parse --show-toplevel', { silent: true })
.output.slice(0, -1);
var topLevel = gup.findGitRoot();
if (test('-f', topLevel + '/.git')) {
// this is a sub module
var buf = fs.readFileSync(topLevel + '/.git', "utf8").trim();
Expand Down
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ function install(hook, dest, cb) {
if (typeof cb !== 'function') cb(new Error('Callback must be a function.'));
if (hooks.indexOf(hook) === -1) cb(new Error('Invalid hook name.'));

dest = ((typeof dest === 'function' ? null : dest) ||
exec('git rev-parse --show-toplevel')
.output.slice(0, -1) + '/.git/hooks/');
dest = (typeof dest === 'function' ? null : dest) || findGitRoot() + '/.git/hooks/';

var destHook = path.join(dest, hook);

Expand Down

0 comments on commit 636657d

Please sign in to comment.