lib/git-hooks-debug.js
function (workingDirectory) {
        var gitPath = getClosestGitPath(workingDirectory);

        if (!gitPath) {
            throw new Error('git-hooks must be run inside a git repository');
        }

        var hooksPath = path.resolve(gitPath, HOOKS_DIRNAME);
        var pathToGitHooks = path.join(path.relative(hooksPath, __dirname), 'git-hooks');
 
        if (isWin32) {
            pathToGitHooks = pathToGitHooks.replace(/\\/g, '\\\\');
        }

        if (fsHelpers.exists(hooksOldPath)) {
            throw new Error('git-hooks already installed');
        }

        if (fsHelpers.exists(hooksPath)) {
            fs.renameSync(hooksPath, hooksOldPath);
        }

        var hookTemplate = fs.readFileSync(__dirname + '/' + HOOKS_TEMPLATE_FILE_NAME);
        var pathToGitHooks = path.relative(hooksPath, __dirname);
        // Fix non-POSIX (Windows) separators
        pathToGitHooks = pathToGitHooks.replace(new RegExp(path.sep.replace(/\\/g, '\\$&'), 'g'), '/');
        var hook = util.format(hookTemplate.toString(), pathToGitHooks);

        fsHelpers.makeDir(hooksPath);
        HOOKS.forEach(function (hookName) {
            var hookPath = path.resolve(hooksPath, hookName);
            try {
                fs.writeFileSync(hookPath, hook, {mode: '0777'});
            } catch (e) {
                // node 0.8 fallback
                fs.writeFileSync(hookPath, hook, 'utf8');
                fs.chmodSync(hookPath, '0777');
            }
        });
    }
function (workingDirectory) {
        var gitPath = getClosestGitPath(workingDirectory);

        if (!gitPath) {
            throw new Error('git-hooks must be run inside a git repository');
        }

        var hooksPath = path.resolve(gitPath, HOOKS_DIRNAME);
        var pathToGitHooks = path.join(path.relative(hooksPath, __dirname), 'git-hooks');
 
        if (isWin32) {
            pathToGitHooks = pathToGitHooks.replace(/\\/g, '\\\\');
        }

        if (fsHelpers.exists(hooksOldPath)) {
            throw new Error('git-hooks already installed');
        }

        if (fsHelpers.exists(hooksPath)) {
            fs.renameSync(hooksPath, hooksOldPath);
        }

        var hookTemplate = fs.readFileSync(__dirname + '/' + HOOKS_TEMPLATE_FILE_NAME);
        var pathToGitHooks = path.relative(hooksPath, __dirname);
        // Fix non-POSIX (Windows) separators
        pathToGitHooks = pathToGitHooks.replace(new RegExp(path.sep.replace(/\\/g, '\\$&'), 'g'), '/');
        var hook = util.format(hookTemplate.toString(), pathToGitHooks);

        fsHelpers.makeDir(hooksPath);
        HOOKS.forEach(function (hookName) {
            var hookPath = path.resolve(hooksPath, hookName);
            try {
                fs.writeFileSync(hookPath, hook, {mode: '0777'});
            } catch (e) {
                // node 0.8 fallback
                fs.writeFileSync(hookPath, hook, 'utf8');
                fs.chmodSync(hookPath, '0777');
            }
        });
    }
function ( workingDirectory ) { var gitPath = getClosestGitPath ( workingDirectory ) ; if ( ! gitPath ) { throw new Error ( 'git-hooks must be run inside a git repository' ) ; } var hooksPath = path . resolve ( gitPath , HOOKS_DIRNAME ) ; var pathToGitHooks = path . join ( path . relative ( hooksPath , __dirname ) , 'git-hooks' ) ; if ( isWin32 ) { pathToGitHooks = pathToGitHooks . replace ( / \\ / g , '\\\\' ) ; } if ( fsHelpers . exists ( hooksOldPath ) ) { throw new Error ( 'git-hooks already installed' ) ; } if ( fsHelpers . exists ( hooksPath ) ) { fs . renameSync ( hooksPath , hooksOldPath ) ; } var hookTemplate = fs . readFileSync ( __dirname + '/' + HOOKS_TEMPLATE_FILE_NAME ) ; var pathToGitHooks = path . relative ( hooksPath , __dirname ) ; // Fix non-POSIX (Windows) separators pathToGitHooks = pathToGitHooks . replace ( new RegExp ( path . sep . replace ( / \\ / g , '\\$&' ) , 'g' ) , '/' ) ; var hook = util . format ( hookTemplate . toString ( ) , pathToGitHooks ) ; fsHelpers . makeDir ( hooksPath ) ; HOOKS . forEach ( function ( hookName ) { var hookPath = path . resolve ( hooksPath , hookName ) ; try { fs . writeFileSync ( hookPath , hook , { mode : '0777' } ) ; } catch ( e ) { // node 0.8 fallback fs . writeFileSync ( hookPath , hook , 'utf8' ) ; fs . chmodSync ( hookPath , '0777' ) ; } } ) ; }
Installs git hooks.

@param {String} [workingDirectory]
@throws {Error}
Installs git hooks .