Runs a short OS query and resolves its stdout, or null when it fails or times out.
(file: string, args: string[])
| 48 | |
| 49 | /** Runs a short OS query and resolves its stdout, or null when it fails or times out. */ |
| 50 | function query(file: string, args: string[]): Promise<string | null> { |
| 51 | return new Promise((resolve) => { |
| 52 | try { |
| 53 | execFile(file, args, { encoding: 'utf8', timeout: lookupTimeoutMs(), windowsHide: true, maxBuffer: 1 << 20 }, |
| 54 | (error, stdout) => resolve(error ? null : stdout)); |
| 55 | } catch { |
| 56 | resolve(null); |
| 57 | } |
| 58 | }); |
| 59 | } |
| 60 | |
| 61 | function windowsTool(...parts: string[]): string { |
| 62 | return path.join(process.env.SystemRoot || process.env.windir || 'C:\\Windows', 'System32', ...parts); |
no test coverage detected