runCommand static method
Implementation
static Future<String> runCommand(String workDir, String command) async {
ProcessResult processResult;
if (Platform.isWindows) {
processResult = await Process.run('cmd', [
'/c',
command,
], workingDirectory: workDir);
} else {
processResult = await Process.run('bash', [
'-c',
command,
], workingDirectory: workDir);
}
if (processResult.exitCode == 0) {
return processResult.stdout.toString();
} else {
throw CommandException(command, processResult.stderr.toString());
}
}