Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async getVersions(throwOnError?: boolean): Promise {
const versions = { docker: '', compose: '' };
try {
debug('fetching docker version');
const dockerVersion = await new Dockerode().version();
debug(`Result: ${JSON.stringify(dockerVersion)}`);
versions.docker = dockerVersion.Version;
} catch (error) {
debug(`Failed: ${error.message}`);
if (throwOnError) throw error;
}
try {
debug('getting docker-compose version');
const composeVersion = await this.execute(compose.version, this.getArgs());
debug(`Result: ${JSON.stringify(composeVersion)}`);
versions.compose = composeVersion.out.trim();
} catch (error) {
debug(`Failed: ${error.message}`);
if (throwOnError) throw error;
}
return versions;
}