Specifies a current working directory, instead of the default ./. Use this flag to perform an operation in a working directory that is not the current one.
This can make scripts nicer by avoiding the need to cd into a folder and then cd back out.
从文档的描述来看,cwd 的作用不就是代替 cd 吗,但现在的结果看来 yarn --cwd ../ preinstall 并不等价于 cd ../ && yarn preinstall 。
下面聊些不太成熟的观点,在项目的实践中,特别是开源前端组件库,经常会面临一个选择困境:我们不得不对某个 API 做出 breaking change,然而这个 API 仅在少数场景下被使用到,如果严格遵循语义化版本,那我们将要升级主版本号,但是对于用户而言,会认为是整个组件库得到了升级,所以我认为这一点上还是需要根据实际情况做考虑。
if (status !== 0) { const noVerifyMessage = [ 'commit-msg', 'pre-commit', 'pre-rebase', 'pre-push' ].includes(hookName) ? '(add --no-verify to bypass)' : '(cannot be bypassed with --no-verify due to Git specs)'
// Set or add command in hook const hook = (fn: (a1: string, a2: string) => void) => (): void => // Show usage if no arguments are provided or more than 2 !ln || ln > 2 ? help(2) : fn(x, y)
exportfunctioninstall(dir = '.husky'): void{ if (process.env.HUSKY === '0') { l('HUSKY env variable is set to 0, skipping install') return }
// Ensure that we're inside a git repository // If git command is not found, status is null and we should return. // That's why status value needs to be checked explicitly. if (git(['rev-parse']).status !== 0) { return }
// Custom dir help const url = 'https://typicode.github.io/husky/#/?id=custom-directory'
// Ensure that we're not trying to install outside of cwd if (!p.resolve(process.cwd(), dir).startsWith(process.cwd())) { thrownewError(`.. not allowed (see ${url})`) }
// Ensure that cwd is git top level if (!fs.existsSync('.git')) { thrownewError(`.git can't be found (see ${url})`) }
A page is in the terminated state once it has started being unloaded and cleared from memory by the browser. No new tasks can start in this state, and in-progress tasks may be killed if they run too long.
Possible previous states: hidden(via the pagehide event)
Note: For historical reasons, a user agent MAY change the request method from POST to GET for the subsequent request. If this behavior is undesired, the 307 (Temporary Redirect) status code can be used instead.
简而言之就是因为历史原因,当某些 HTTP/1.0 客户端收到该状态码时,可能会将 POST 方法改为 GET 方法,继续向新地址发出请求,这是错误的实现——故而后续标准引入了 HTTP 307。
所以最好只在 GET 或 HEAD 方法时使用 301,其他情况使用 307 或者 308 来替代 301。
for d in"${dir[@]}"; do # 判断是否修改工具方法、测试用例,无则跳过 has_change=$(hg status | grep "${d}") if [ -z "$has_change" ]; thencontinue; fi # 同一个项目只执行一次 [ $pass -eq 1 ] && break
cd"$d" || exit 1 yarn && yarn test
# test 是否报错,是则直接退出脚本 if [ $? -ne 0 ]; thenexit 1; fi
/Users/4ark/project/helper/404.js 9:7 error 'a' is assigned a value but never used no-unused-vars
✖ 1 problem (1 error, 0 warnings)
error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. abort: pre-commit hook exited with status 1
而 vscode-hg 只输出如下:
1 2
error Command failed with exit code 1. abort: pre-commit hook exited with status 1
首先我并不认同这种说法,因为他没有给出专业的对比分析,即便这是真的,但在我们负责的这种 Web 项目中,这种速度的提升简直是可以忽略不计的,所以我就「可读性」本身这件事与他讨论,结果他开始和我解释这个位运算符是如何工作的,这位同学就犯了上面提到的问题,其实我不是不理解位运算符如何工作,我还曾写过一篇《深入理解按位操作符》的文章,我只是单纯认为不应该在项目中使用位运算符罢了。