如何在bash脚本中使用git fetch / pull提供密码短语。我真的需要在bash脚本中执行此操作,而无需使用ssh-add或类似的内容。可能吗?
例如,我发现了一些基于 promise 的 api 库,我需要在某个时间间隔内使用该库发出 api 请求,无限次(如通常的后端循环)。这个 api 请求 - 实际上是承诺链。
所以,如果我写这样的函数:
function r(){
return api
.call(api.anotherCall)
.then(api.anotherCall)
.then(api.anotherCall)
...
.then(r)
}
Run Code Online (Sandbox Code Playgroud)
会导致堆栈溢出吗?
我想出的解决方案是使用 setTimeout 进行r递归调用。
function r(){
return api
.call(api.anotherCall)
.then(api.anotherCall)
.then(api.anotherCall)
.then(()=>{setTimeout(r, 0)})
}
Run Code Online (Sandbox Code Playgroud)
所以 setTimeoutr只会在调用栈为空时才会调用。
这是好的解决方案,还是有一些递归调用承诺的标准方法?