✨ feat(vscode): 新增 GitHub provider,凭据借 gh 登录,删工单走 GraphQL、依赖按内部 id 换算
This commit is contained in:
1 parent
451bc91a6b
commit
7351b6247f
12 files changed
+1010
-47
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { existsSync } from 'node:fs'
|
||||
import * as path from 'node:path'
|
||||
import process from 'node:process'
|
||||
|
||||
/**
|
||||
* 找命令行工具的绝对路径:先找 `env.PATH` 各目录下的 `name`,再按顺序试 `fallbacks`;都没有返回 `null`。
|
||||
*
|
||||
* 从程序坞启动的 VS Code 拿到的 PATH 常常不全,只靠 PATH 会把装了的工具当成没装。
|
||||
*/
|
||||
export function findExecutable(name: string, fallbacks: readonly string[], env: NodeJS.ProcessEnv = process.env): string | null {
|
||||
for (const dir of (env.PATH ?? '').split(path.delimiter)) {
|
||||
if (!dir)
|
||||
continue
|
||||
const candidate = path.join(dir, name)
|
||||
if (existsSync(candidate))
|
||||
return candidate
|
||||
}
|
||||
for (const candidate of fallbacks) {
|
||||
if (existsSync(candidate))
|
||||
return candidate
|
||||
}
|
||||
return null
|
||||
}
|
||||
Reference in new issue
Block a user