Implementation
Future<int> get run async {
final commandCli = CommandlineConverter().convert(this);
final executable = commandCli.first;
final arguments = commandCli.sublist(1);
final process = await Process.start(
executable,
arguments,
runInShell: true,
environment: Platform.environment,
);
process.stdout.transform(utf8.decoder).listen(
(line) {
printMessage(line.replaceAll(RegExp(r'[\s\n]+$'), ''));
},
);
process.stderr.transform(utf8.decoder).listen(
(line) {
printerrMessage(line.replaceAll(RegExp(r'[\s\n]+$'), ''));
},
);
final exitCode = await process.exitCode;
if (exitCode > 0) {
throw Exception('$this has exit with code $exitCode');
}
return exitCode;
}