(command, args, options = {})
| 1776 | } |
| 1777 | |
| 1778 | function runText(command, args, options = {}) { |
| 1779 | const startedAt = Date.now(); |
| 1780 | logCommand(command, args); |
| 1781 | const result = spawnSync(command, args, { |
| 1782 | cwd: root, |
| 1783 | encoding: "utf8", |
| 1784 | input: options.input, |
| 1785 | env: options.env ? { ...process.env, ...options.env } : process.env, |
| 1786 | timeout: options.timeoutMs ?? 120_000, |
| 1787 | }); |
| 1788 | if (result.status !== 0) { |
| 1789 | throw new Error( |
| 1790 | `${command} ${args.join(" ")} failed with ${result.status ?? result.signal}\n${result.stdout}\n${result.stderr}`, |
| 1791 | ); |
| 1792 | } |
| 1793 | const elapsedMs = Date.now() - startedAt; |
| 1794 | recordCommandTiming(command, args, elapsedMs); |
| 1795 | if (options.maxElapsedMs && elapsedMs > options.maxElapsedMs) { |
| 1796 | throw new Error( |
| 1797 | `${command} ${args.join(" ")} took ${elapsedMs}ms, above ${options.maxElapsedMs}ms budget`, |
| 1798 | ); |
| 1799 | } |
| 1800 | logCommandResult(command, args, elapsedMs, result.stdout); |
| 1801 | return result.stdout; |
| 1802 | } |
| 1803 | |
| 1804 | function runBuffer(command, args, options = {}) { |
| 1805 | const startedAt = Date.now(); |
no test coverage detected