Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support submodules #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion install.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var fs = require('fs')
, spawn = require('cross-spawn')
, hook = path.join(__dirname, 'hook')
, root = path.resolve(__dirname, '..', '..')
, execSync = require('child_process').execSync
, exists = fs.existsSync || path.existsSync;

//
Expand All @@ -16,7 +17,9 @@ var fs = require('fs')
// `pre-commit` file. The path needs to be absolute in order for the symlinking
// to work correctly.
//
var git = path.resolve(root, '.git')

var config = execSync('git rev-parse --git-dir', { cwd: root }).toString().trim()
, git = path.resolve(root, config)
, hooks = path.resolve(git, 'hooks')
, precommit = path.resolve(hooks, 'pre-commit');

Expand Down
11 changes: 7 additions & 4 deletions uninstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@

var fs = require('fs')
, path = require('path')
, execSync = require('child_process').execSync
, exists = fs.existsSync || path.existsSync
, precommit = path.resolve(__dirname, '../..', '.git', 'hooks', 'pre-commit');
, root = path.resolve(__dirname, '..', '..')
, config = execSync('git rev-parse --git-dir', { cwd: root }).toString().trim()
, precommit = path.resolve(root, config, 'hooks', 'pre-commit');

//
// Bail out if we don't have pre-commit file, it might be removed manually.
//
if (!exists(precommit)) return;

fs.unlinkSync(precommit);

//
// If we don't have an old file, we should just remove the pre-commit hook. But
// if we do have an old precommit file we want to restore that.
//
if (!exists(precommit +'.old')) {
fs.unlinkSync(precommit);
} else {
if (exists(precommit +'.old')) {
fs.writeFileSync(precommit, fs.readFileSync(precommit +'.old'));
fs.chmodSync(precommit, '755');
fs.unlinkSync(precommit +'.old');
Expand Down