import chalk from 'chalk';
export const checkDocker = async function () {
    if (this.abort || this.skipChecks)
        return;
    const ret = await this.spawnCommand('docker -v', { reject: false, stdio: 'pipe' });
    if (ret.exitCode !== 0) {
        this.log.error(chalk.red(`Docker version 1.10.0 or later is not installed on your computer.
         Read http://docs.docker.com/engine/installation/#installation
`));
        throw new Error();
    }
    const dockerVersion = ret.stdout.split(' ')[2].replace(/,/g, '');
    const dockerVersionMajor = dockerVersion.split('.')[0];
    const dockerVersionMinor = dockerVersion.split('.')[1];
    if (dockerVersionMajor < 1 || (dockerVersionMajor === 1 && dockerVersionMinor < 10)) {
        this.log.error(chalk.red(`Docker version 1.10.0 or later is not installed on your computer.
                               Docker version found: ${dockerVersion}
                               Read http://docs.docker.com/engine/installation/#installation`));
        throw new Error();
    }
    else {
        this.log.verboseInfo('Docker is installed');
    }
};
export default {
    checkDocker,
};
