Skip to content

Commit

Permalink
Enable java environments check
Browse files Browse the repository at this point in the history
  • Loading branch information
int64ago committed Dec 24, 2016
1 parent d0759c9 commit c578566
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ const path = require('path');
const crypto = require('crypto');
const execFile = require('child_process').execFile;

const javaVersion = (callback) => {
execFile('java', ['-version'], callback);
};

class Freemarker {
constructor(options = {}) {
this.tmpDir = os.tmpdir();
Expand Down Expand Up @@ -68,13 +72,16 @@ class Freemarker {
};
this._writeData(tddFile, data);
this._writeConfig(configFile, config);
execFile(this.cmd, [ftl, '-C', configFile], (err, log) => {
let result = '';
if (fs.existsSync(htmlFile)) {
result = fs.readFileSync(htmlFile, 'utf8');
}
callback(err? log: null, result);
this._cleanFiles([htmlFile, tddFile, configFile]);
javaVersion(err => {
if (err) return callback('Java is not set properly!');
execFile(this.cmd, [ftl, '-C', configFile], (err, log) => {
let result = '';
if (fs.existsSync(htmlFile)) {
result = fs.readFileSync(htmlFile, 'utf8');
}
callback(err? log: null, result);
this._cleanFiles([htmlFile, tddFile, configFile]);
});
});
}
};
Expand Down

0 comments on commit c578566

Please sign in to comment.