install method
Installs exactly version of the CLI.
Throws a CliUpdateFailedException if the install could not be run or did not succeed.
Implementation
@override
Future<void> install(
final Version version, {
required final CommandLogger logger,
}) async {
final arguments = installArguments(installation, version: version);
logger.debug('Installing $_cliPackageName $version: $arguments');
final ProcessResult result;
try {
result = await Process.run(_dartExecutable, arguments);
} on ProcessException catch (e, stackTrace) {
logger.debug('Failed to run the install command: $e\n$stackTrace');
throw CliUpdateFailedException(
version: version,
reason: 'the install command could not be run: ${e.message}',
);
}
if (result.exitCode != 0) {
logger.debug(
'The install command exited with ${result.exitCode}.\n'
'${result.stdout}\n${result.stderr}',
);
throw CliUpdateFailedException(
version: version,
reason: 'the install command exited with ${result.exitCode}',
);
}
}