MCPcopy Create free account
hub / github.com/anus-dev/ANUS / imageExists

Function imageExists

packages/cli/src/utils/sandbox.ts:818–846  ·  view source on GitHub ↗
(sandbox: string, image: string)

Source from the content-addressed store, hash-verified

816
817// Helper functions to ensure sandbox image is present
818async 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
848async function pullImage(sandbox: string, image: string): Promise<boolean> {
849 console.info(`Attempting to pull image ${image} using ${sandbox}...`);

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected