Tag: githooks

如何从无限循环停止bash脚本?

我的项目目录中有这样一个名为shrinkwrap.sh的bash脚本: update_package_json_changed_files() { echo "> changed files" git diff –cached –name-only | grep -x package.json } update_shrinkwrap_and_at_to_git_index() { echo "> Updating npm-shrinkwrap.json and adding to current commit." npm shrinkwrap git add npm-shrinkwrap.json } if get_package_json_changed_files; then update_shrinkwrap_and_at_to_git_index fi 我在package.json中运行这个脚本如下: "scripts": { "shrinkwrap": "bin/shrinkwrap.sh" } 我安装了npm pre-commit来执行脚本,如下所示: "pre-commit": ["shrinkwrap"] 当我尝试提交时,脚本进入一个无限循环。 它一直在运行,没有什么可以阻止它。 我试过命令+ C,控制+ Z.没有任何工作。 有没有人遇到过这个问题? 为什么会这样呢?

如何检查一致性npm-shrinkwrap.json和package.json

有时我的团队成员忘记更新package.json之后更新npm-shrinkwrap.json。 我从uber知道这个软件包 ,但不能用于npm v3。 所以现在它不是解决scheme。 我有可能自动检查npm-shrinkwrap.json和package.json的一致性吗? 我想在git-hook或/和连续做这个。

如何在“npm install”上安装git钩子?

当有人安装my-package时候,我想安装一个pre-commit git钩子(即丢掉代码)。 我试图添加一个postinstall脚本: "scripts": { "postinstall": "./scripts/install-git-hooks" } 这很好。 当有人运行npm install ,他们会得到pre-commit安装钩子。 但是,如果another-package依赖于my-package ,则为another-package运行npm install也会运行postinstall脚本,这是不希望的。 什么是最干净的方法来避免这种不良影响?