(workDir: string)
| 243 | } |
| 244 | |
| 245 | function readPullRequest(workDir: string): Promise<PullRequestInfo | null> { |
| 246 | return new Promise((resolve) => { |
| 247 | try { |
| 248 | execFile( |
| 249 | 'gh', |
| 250 | ['pr', 'view', '--json', 'number,url'], |
| 251 | { |
| 252 | cwd: workDir, |
| 253 | encoding: 'utf8', |
| 254 | env: { |
| 255 | ...process.env, |
| 256 | GH_NO_UPDATE_NOTIFIER: '1', |
| 257 | GH_PROMPT_DISABLED: '1', |
| 258 | }, |
| 259 | timeout: PR_SPAWN_TIMEOUT_MS, |
| 260 | maxBuffer: 256 * 1024, |
| 261 | }, |
| 262 | (error, stdout) => { |
| 263 | if (error !== null) { |
| 264 | resolve(null); |
| 265 | return; |
| 266 | } |
| 267 | resolve(parsePullRequest(stdout)); |
| 268 | }, |
| 269 | ); |
| 270 | } catch { |
| 271 | resolve(null); |
| 272 | } |
| 273 | }); |
| 274 | } |
| 275 | |
| 276 | function samePullRequest(a: PullRequestInfo | null, b: PullRequestInfo | null): boolean { |
| 277 | if (a === null || b === null) return a === b; |
no test coverage detected