/* Installs hook in grunt/hooks/source as .git/hooks/dest
425384
function installHook( source, dest, sourceCanonicalName, cb ) {
		var hookToCopy = path.join( ( options.hookDir || 'grunt/hooks/' ), source );
		var whereToPutIt = '.git/hooks/' + dest;
		if ( !fs.existsSync( hookToCopy ) ) {
			grunt.fail.fatal( 'No file found at ' + hookToCopy );
		}

		// If there is already that type of hook installed
		if ( fs.existsSync( './' + whereToPutIt ) ) {

			// Ask if the user wants to overwrite the existing hook
			getYesNoResponse( [
					'A hook already exists at',
					whereToPutIt + '.',
					'Do you wish to overwrite it?'
				].join( ' ' ).red,
				function() {

					// The user said yes. Overwrite the existing hook.
					actuallyInstallHook(
						hookToCopy,
						whereToPutIt,
						sourceCanonicalName
					);

					cb();
				},
				function() {

					// The user said no, tell they we're skipping the hook
					grunt.log.writeln( [
						'Skipping install of ',
						sourceCanonicalName,
						' hook in ',
						whereToPutIt
					].join( '' ).red);

					cb();
				}
			);

		} else {

			// The file didn't exist, perform the copy and continue
			grunt.log.writeln( hookToCopy, whereToPutIt, sourceCanonicalName );
			actuallyInstallHook(
				hookToCopy,
				whereToPutIt,
				sourceCanonicalName
			);
			cb();
		}

		// Installs the hook without checking if it already exists
		function actuallyInstallHook(
			hookToCopy,
			whereToPutIt,
			sourceCanonicalName
		) {
			mkpath.sync( path.join( './', path.dirname( whereToPutIt ) ) );
			exec( 'cp ' + hookToCopy + ' ' + whereToPutIt );
			grunt.log.writeln( [
				'Installed ', sourceCanonicalName, ' hook in ', whereToPutIt
			].join( '' ).green );
		}
	}
532033
def add_hook(hook, &block)
      fail ArgumentError, "Invalid hook `#{hook}'" unless\
        HOOKS.keys.include? hook
      fail ArgumentError, 'Block require' unless block_given?
      options[hook] = block
    end
1234046
function installHookDependencies() {
		return Promise.all(hookDependencies.map(function (dependency) {
			return pify(npmi, Promise)({name: dependency, path: path.join(process.env.PWD, 'hooks')});
		}));
	}
1136503
def install_hook(ctx):
    
    try:
        lint_config = ctx.obj[0]
        hooks.GitHookInstaller.install_commit_msg_hook(lint_config)
        # declare victory :-)
        hook_path = hooks.GitHookInstaller.commit_msg_hook_path(lint_config)
        click.echo(u"Successfully installed gitlint commit-msg hook in {0}".format(hook_path))
        ctx.exit(0)
    except hooks.GitHookInstallerError as e:
        click.echo(ustr(e), err=True)
        ctx.exit(GIT_CONTEXT_ERROR_CODE)
425316
function compileBody(str, options){
  var debug_sources = {};
  debug_sources[options.filename] = str;
  var dependencies = [];
  var plugins = options.plugins || [];
  var ast = load.string(str, {
    filename: options.filename,
    basedir: options.basedir,
    lex: function (str, options) {
      var lexOptions = {};
      Object.keys(options).forEach(function (key) {
        lexOptions[key] = options[key];
      });
      lexOptions.plugins = plugins.filter(function (plugin) {
        return !!plugin.lex;
      }).map(function (plugin) {
        return plugin.lex;
      });
      var contents = applyPlugins(str, {filename: options.filename}, plugins, 'preLex');
      return applyPlugins(lex(contents, lexOptions), options, plugins, 'postLex');
    },
    parse: function (tokens, options) {
      tokens = tokens.map(function (token) {
        if (token.type === 'path' && path.extname(token.val) === '') {
          return {
            type: 'path',
            loc: token.loc,
            val: token.val + '.pug'
          };
        }
        return token;
      });
      tokens = stripComments(tokens, options);
      tokens = applyPlugins(tokens, options, plugins, 'preParse');
      var parseOptions = {};
      Object.keys(options).forEach(function (key) {
        parseOptions[key] = options[key];
      });
      parseOptions.plugins = plugins.filter(function (plugin) {
        return !!plugin.parse;
      }).map(function (plugin) {
        return plugin.parse;
      });

      return applyPlugins(
        applyPlugins(parse(tokens, parseOptions), options, plugins, 'postParse'),
        options, plugins, 'preLoad'
      );
    },
    resolve: function (filename, source, loadOptions) {
      var replacementFunc = findReplacementFunc(plugins, 'resolve');
      if (replacementFunc) {
        return replacementFunc(filename, source, options);
      }

      return load.resolve(filename, source, loadOptions);
    },
    read: function (filename, loadOptions) {
      dependencies.push(filename);

      var contents;

      var replacementFunc = findReplacementFunc(plugins, 'read');
      if (replacementFunc) {
        contents = replacementFunc(filename, options);
      } else {
        contents = load.read(filename, loadOptions);
      }

      var str = applyPlugins(contents, {filename: filename}, plugins, 'preLex');
      debug_sources[filename] = str;
      return str;
    }
  });
  ast = applyPlugins(ast, options, plugins, 'postLoad');
  ast = applyPlugins(ast, options, plugins, 'preFilters');

  var filtersSet = {};
  Object.keys(exports.filters).forEach(function (key) {
    filtersSet[key] = exports.filters[key];
  });
  if (options.filters) {
    Object.keys(options.filters).forEach(function (key) {
      filtersSet[key] = options.filters[key];
    });
  }
  ast = filters.handleFilters(ast, filtersSet, options.filterOptions, options.filterAliases);

  ast = applyPlugins(ast, options, plugins, 'postFilters');
  ast = applyPlugins(ast, options, plugins, 'preLink');
  ast = link(ast);
  ast = applyPlugins(ast, options, plugins, 'postLink');

  // Compile
  ast = applyPlugins(ast, options, plugins, 'preCodeGen');
  var js = generateCode(ast, {
    pretty: options.pretty,
    compileDebug: options.compileDebug,
    doctype: options.doctype,
    inlineRuntimeFunctions: options.inlineRuntimeFunctions,
    globals: options.globals,
    self: options.self,
    includeSources: options.includeSources ? debug_sources : false,
    templateName: options.templateName
  });
  js = applyPlugins(js, options, plugins, 'postCodeGen');
  // Debug compiler
  if (options.debug) {
    console.error('\nCompiled Function:\n\n\u001b[90m%s\u001b[0m', js.replace(/^/gm, '  '));
  }

  return {body: js, dependencies: dependencies};
}
1233306
def uninstall_hook(ctx):
    
    try:
        lint_config = ctx.obj[0]
        hooks.GitHookInstaller.uninstall_commit_msg_hook(lint_config)
        # declare victory :-)
        hook_path = hooks.GitHookInstaller.commit_msg_hook_path(lint_config)
        click.echo(u"Successfully uninstalled gitlint commit-msg hook from {0}".format(hook_path))
        ctx.exit(0)
    except hooks.GitHookInstallerError as e:
        click.echo(ustr(e), err=True)
        ctx.exit(GIT_CONTEXT_ERROR_CODE)
860891
function(files, callback) {
            if (files.dest) {
                options['output'] = files.dest;
            }

			var commandLine = compcOptions.toCommandLine(options);

            if (files.src && files.src.length > 0) {                
                commandLine.push('-include-sources');
                commandLine.push.apply(commandLine, files.src);
                commandLine.push('--');
            }
            
			grunt.verbose.writeln('compc path: ' + binary);
			grunt.verbose.writeln('options: ' + commandLine);
		
			childProcess.execFile(binary, commandLine, function(error, stdout, stderr) {
                grunt.verbose.writeln('output: ' + stdout);
                
				if (error) {
					grunt.log.error(error.toString());
                    
                    if (options.force !== true) {
                        grunt.fail.warn('Compc task has failed.');
                    }                    
				}
                else if (files.dest) {
                    grunt.log.writeln('Build complete: ' + files.dest);
                }
                
                callback(error);
			});
		}
137899
function(grunt) {
		var me = this;
		
		this.hookChild(
			grunt.util,
			'spawn',
			function(original, spawnArgs) {
				var options = spawnArgs[0];
				var callback = spawnArgs[1];
				
				if (options.cmd === process.argv[0]) {
					var module;
					
					for (var i = 0; i < options.args.length; i++) {
						if (options.args[i].lastIndexOf('--') != 0) {
							module = options.args[i];
							break;
						}
					}
					
					me.addDebugArg(options.args, module);
				}
				
				return original.call(this, options, callback);
			}
		);
	}
469927
function gitTags(wd) {
  const basename = path.basename(wd);
  const keys = ['tag_name', 'datetime_created'];
  const separator = '_,,,_';
  const cmd = `git for-each-ref --format='%(refname:short)${separator}%(taggerdate)' refs/tags`;

  console.log(`Collecting git tags of repo ${chalk.cyan(basename)}`);
  const gitProcess = exec(cmd, {
    cwd: wd
  });
  const rl = readline.createInterface({
    input: gitProcess.stdout
  });

  const tagStats = [];
  return new Promise((resolve, reject) => {
    gitProcess.on('error', (err) => {
      reject(err);
    });

    rl.on('line', (line) => {
      const entry = line.split(separator);
      tagStats.push({
        tag_name: entry[0],
        datetime_created: new Date(entry[1]).toISOString()
      });
    }).on('close', () => {
      if (tagStats.length === 0) {
        reject(new Error(chalk.red(`No tags added to this repo`)));
      }
      resolve(tagStats);
    });

  });
}
1024077
function (grunt, rootPath, tasks) {
		tasks.forEach(function (name) {
			if (name === 'grunt-cli') return;
			var cwd = process.cwd();
			process.chdir(rootPath); // load files from proper root, I don't want to install everything locally per module!
			grunt.loadNpmTasks(name);
			process.chdir(cwd);
		});
	}
1002592
function addHookByType(ctx, type, methodNames, fn) {
  let i = methodNames.length;

  // If no hook specified, add wildcard
  if (i === 0) {
    methodNames = ['*'];
    i = 1;
  }

  let hookType = `${type}Hooks`;

  if (!ctx[hookType]) ctx[hookType] = {};

  while (i--) {
    let methodName = methodNames[i];
    // for array method names
    if (Array.isArray(methodName)) {
      addHookByType(ctx, type, methodName, fn);
    } else {
      if (!ctx[hookType][methodName]) {
        ctx[hookType][methodName] = [fn];
      } else {
        ctx[hookType][methodName].push(fn);
      }
    }
  }
}
966789
def _run_hooks(config, hooks, args, environ):
    """"""
    skips = _get_skips(environ)
    cols = _compute_cols(hooks, args.verbose)
    filenames = _all_filenames(args)
    filenames = filter_by_include_exclude(filenames, '', config['exclude'])
    classifier = Classifier(filenames)
    retval = 0
    for hook in hooks:
        retval |= _run_single_hook(classifier, hook, args, skips, cols)
        if retval and config['fail_fast']:
            break
    if retval and args.show_diff_on_failure and git.has_diff():
        if args.all_files:
            output.write_line(
                'pre-commit hook(s) made changes.\n'
                'If you are seeing this message in CI, '
                'reproduce locally with: `pre-commit run --all-files`.\n'
                'To run `pre-commit` as part of git workflow, use '
                '`pre-commit install`.',
            )
        output.write_line('All changes made by hooks:')
        subprocess.call(('git', '--no-pager', 'diff', '--no-ext-diff'))
    return retval
1321321
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 hooksOldPath = path.resolve(gitPath, HOOKS_OLD_DIRNAME);

        if (!fsHelpers.exists(hooksPath)) {
            throw new Error('git-hooks is not installed');
        }

        fsHelpers.removeDir(hooksPath);

        if (fsHelpers.exists(hooksOldPath)) {
            fs.renameSync(hooksOldPath, hooksPath);
        }
    }
1366756
func copyHook(hookType HookType, hookExecutable, hookDestPath string) error {
	task := fmt.Sprintf("Install the SalsaFlow git %v hook", hookType)
	if err := fileutil.CopyFile(hookExecutable, hookDestPath); err != nil {
		return errs.NewError(task, err)
	}
	if err := os.Chmod(hookDestPath, 0750); err != nil {
		return errs.NewError(task, err)
	}
	log.Log(fmt.Sprintf("SalsaFlow git %v hook installed", hookType))
	return nil
}
457717
function gitTag() {
      return function() {
        var deferred = Q.defer();

        if (!grunt.option('version')) {
          throw new Error('Error in step [Git tag]. Version is not defined.');
        }
        Q.fcall(command(format('git tag -a v%s -m \'%s\'', grunt.option('version'), options.tag.replace('%v', grunt.option('version'))), 'Git tag'))
        //Q.fcall(command(format('echo "git tag -a v%s -m \'%s\'"', grunt.option('version'), options.tag.replace('%v', grunt.option('version'))), 'Git tag', false))//TODO:temp
          .then(function( data ) {
            deferred.resolve(data);
          })
          .catch(function( err ) {
            deferred.reject(err);
          });
        return deferred.promise;
      };
    }
985208
function(callback) {
            if (!file.isDirectory()) {
              callback();
              return;
            }

            grunt.log.write(wrap('d--------- /' + file.dest));
            ftpout.raw.mkd(file.dest, function(err) {
              if (err) {
                if (err.code != 550) {
                  done(err);
                } else {
                  grunt.log.writeln(wrapRight('[PRESENT]').yellow);
                }
              } else {
                grunt.log.writeln(wrapRight('[SUCCESS]').green);
              }
              callback();
            });
          }
1028123
function tree (dir, opts, cb) {
  var i = 0
  findPackage(dir, function (err, pkg) {
    pull(
      pull.depthFirst(pkg, function (pkg) {
        pkg.tree = {}
        return pull(
          pfs.readdir(path.resolve(pkg.path, 'node_modules')),
          paramap(maybe(readPackage)),
          pull.filter(function (_pkg) {
            if(!_pkg) return
            _pkg.parent = pkg
            
            pkg.tree[_pkg.name] = _pkg
            return pkg
          })
        )
      }),
      opts.post ? paramap(function (data, cb) {
        //run a post install-style hook.
        opts.post(data, cb)
      }) : pull.through(),
      pull.drain(null, function (err) {
        cb(err === true ? null : err, clean(pkg))
      })
    )
  })
}