(sandbox: string, image: string)
| 816 | |
| 817 | // Helper functions to ensure sandbox image is present |
| 818 | async function imageExists(sandbox: string, image: string): Promise<boolean> { |
| 819 | return new Promise((resolve) => { |
| 820 | const args = ['images', '-q', image]; |
| 821 | const checkProcess = spawn(sandbox, args); |
| 822 | |
| 823 | let stdoutData = ''; |
| 824 | if (checkProcess.stdout) { |
| 825 | checkProcess.stdout.on('data', (data) => { |
| 826 | stdoutData += data.toString(); |
| 827 | }); |
| 828 | } |
| 829 | |
| 830 | checkProcess.on('error', (err) => { |
| 831 | console.warn( |
| 832 | `Failed to start '${sandbox}' command for image check: ${err.message}`, |
| 833 | ); |
| 834 | resolve(false); |
| 835 | }); |
| 836 | |
| 837 | checkProcess.on('close', (code) => { |
| 838 | // Non-zero code might indicate docker daemon not running, etc. |
| 839 | // The primary success indicator is non-empty stdoutData. |
| 840 | if (code !== 0) { |
| 841 | // console.warn(`'${sandbox} images -q ${image}' exited with code ${code}.`); |
| 842 | } |
| 843 | resolve(stdoutData.trim() !== ''); |
| 844 | }); |
| 845 | }); |
| 846 | } |
| 847 | |
| 848 | async function pullImage(sandbox: string, image: string): Promise<boolean> { |
| 849 | console.info(`Attempting to pull image ${image} using ${sandbox}...`); |
no outgoing calls
no test coverage detected