@Override
public String getVersion() throws IOException {
// Verify that puppet-lint is installed. If not, then refuse to install this bundle
OpenBAStream out = new OpenBAStream();
OpenBAStream err = new OpenBAStream();
File home = new File(System.getProperty("user.home"));
int exitCode = OsUtil.runProcess(home, out, err, getPuppetLintExecutable(), "--version");
String outStr = out.toString(Charset.defaultCharset());
if(exitCode != 0) {
StringBuilder bld = new StringBuilder();
bld.append("Got exit code ");
bld.append(exitCode);
bld.append(" when running puppet-lint.");
outStr = outStr.trim();
if(!outStr.isEmpty()) {
bld.append(" Output \"");
bld.append(outStr);
bld.append('"');
}
String errStr = err.toString(Charset.defaultCharset()).trim();
if(!errStr.isEmpty()) {
bld.append(" Errors \"");
bld.append(errStr);
bld.append('"');
}