博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
虚拟机声音沙哑_防止沙哑的犯错
阅读量:2513 次
发布时间:2019-05-11

本文共 3031 字,大约阅读时间需要 10 分钟。

虚拟机声音沙哑

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 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会构建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# huskyPATH="/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 0npm run precommitif [ $? -ne 0 ]; then  echo  echo "husky - pre-commit hook failed (add --no-verify to bypass)"  echo  exit 1fi

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运行任何您喜欢的命令,例如拼写检查或安全漏洞检查,以确保提交符合您的标准。 我希望我很早以前就知道哈士奇犬-它使设置钩子变得结构化且容易!

翻译自:

虚拟机声音沙哑

转载地址:http://lfvwd.baihongyu.com/

你可能感兴趣的文章
并查集
查看>>
sessionStorage
查看>>
代码示例_进程
查看>>
Java中关键词之this,super的使用
查看>>
学习进度
查看>>
“此人不存在”
查看>>
github.com加速节点
查看>>
解密zend-PHP凤凰源码程序
查看>>
python3 序列分片记录
查看>>
Atitit.git的存储结构and 追踪
查看>>
atitit 读书与获取知识资料的attilax的总结.docx
查看>>
B站 React教程笔记day2(3)React-Redux
查看>>
找了一个api管理工具
查看>>
Part 2 - Fundamentals(4-10)
查看>>
使用Postmark测试后端存储性能
查看>>
NSTextView 文字链接的定制化
查看>>
第五天站立会议内容
查看>>
ATMEGA16 IOport相关汇总
查看>>
JAVA基础-多线程
查看>>
面试题5:字符串替换空格
查看>>