虚拟机声音沙哑_防止沙哑的犯错

虚拟机声音沙哑

I've been contributing to the amazing A-Frame project, a library with allows you to create VR experiences using web technologies, and it's been a blast.  The JavaScript code is very concise and uniform, making contribution a joy while keeping the code standards strict.  Why is it so concise?  The A-Frame project uses a combination of JSHint, which we're all familiar with, but another package I was unfamiliar with:  husky.  Husky builds precommit and other git hooks to run commands within your package.json before a commit is allowed.

我一直在为令人惊叹的A-Frame项目做出贡献,该库可让您使用Web技术创建VR体验,这是一个爆炸。 JavaScript代码非常简洁和统一,在保持严格的代码标准的同时,做出了令人高兴的贡献。 为什么这么简洁? A-Frame项目使用了我们都熟悉的JSHint的组合,但是我不熟悉的另一个包是: husky 。 在允许提交之前,Husky会构建precommit和其他git钩子以在package.json运行命令。

package.json (package.json)

You'll add husky to the devDependencies object within package.json to gain access to the utility during npm install.  Within your scripts object, you'll create a key, precommit for instance, to run JSHint or any other routines you desire.  Here's a reduced sample:

您将添加huskydevDependencies内对象package.json来获得期间进入实用npm install 。 在scripts对象内,您将创建一个键(例如, precommit提交)以运行JSHint或所需的任何其他例程。 这是一个简化的示例:


{
  /* ... */
  "scripts": {
    "lint": "semistandard -v | snazzy",
    "precommit": "npm run lint"
  },
  /* ... */
  "devDependencies": {
    /* ... */
    "husky": "^0.10.1",
    "semistandard": "^7.0.2",
    "snazzy": "^3.0.0"
  }
  /* ... */
}


钩子 (The Hook)

A hook is generated that looks as follows (.git/hooks/pre-commit as an example):

生成一个如下所示的.git/hooks/pre-commit (以.git/hooks/pre-commit为例):


#!/bin/sh
# husky
PATH="/usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/YOURUSER/Projects/aframe/node_modules/husky/node_modules/.bin:/Users/YOURUSER/Projects/aframe/node_modules/.bin:/usr/local/bin:/Users/YOURUSER/.rvm/gems/ruby-2.1.1/bin:/Users/YOURUSER/.rvm/gems/ruby-2.1.1@global/bin:/Users/YOURUSER/.rvm/rubies/ruby-2.1.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/YOURUSER/.rvm/bin"
cd .
[ -f package.json ] && cat package.json | grep -q '"precommit"\s*:'
[ $? -ne 0 ] && exit 0
npm run precommit
if [ $? -ne 0 ]; then
  echo
  echo "husky - pre-commit hook failed (add --no-verify to bypass)"
  echo
  exit 1
fi


The hook checks for a package.json file, then checks to see if there's a scripts key for the hook file it's in; if so, the scripts key command is executed and only if it returns 0 allows the commit to be completed; if there are any lint errors, for example, the commit is not executed and you'll have to fix the nits presented by JSHint.

钩子检查package.json文件,然后检查钩子文件所在的位置是否有scripts键; 如果是,则执行scripts key命令,并且只有返回0才可以完成提交。 例如,如果存在任何皮棉错误,则不会执行提交,您必须修复JSHint提出的问题。

Using husky for JSHint is just an example usage; you can use husky to run any command you like, like spellchecking or security vulnerability checks, to ensure the commit meets your standards.  I wish I knew about husky long ago -- it makes setting up hooks structured and easy!

将husky用于JSHint只是一个例子。 您可以使用husky运行任何您喜欢的命令,例如拼写检查或安全漏洞检查,以确保提交符合您的标准。 我希望我很早以前就知道哈士奇犬-它使设置钩子变得结构化且容易!

翻译自: https://davidwalsh.name/prevent-bad-commits-husky

虚拟机声音沙哑

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值