Fixed PHP detection

This commit is contained in:
Brad Metcalf 2015-05-20 18:08:12 -05:00
commit b6eeb0ef03

View file

@ -9,6 +9,9 @@ var phpwebkit = {
var pw = this;
process.on('uncaughtException', function(err){
if(err == "Error: spawn php-cgi ENOENT") {
err = "Error: PHP doesn't appear to be installed";
}
pw.changeState('<strong>'+err+'</strong>', '#CD0000');
});
@ -27,12 +30,6 @@ var phpwebkit = {
}
}
this.fileExists(bin, function(result){
if(result === false) {
return 'php-cgi';
}
});
var path = gui.App.manifest.phpwebkit.path;
if(path === undefined || path == "") {
path = './application';
@ -48,16 +45,22 @@ var phpwebkit = {
port = 0;
}
var config = {
"path": path,
"bin": bin,
"host": host,
"port": port,
"arguments": gui.App.argv,
"manifest": gui.App.manifest
}
this.fileExists(bin, function(result){
if(result === false) {
bin = 'php-cgi';
}
this.startServer(config);
var config = {
"path": path,
"bin": bin,
"host": host,
"port": port,
"arguments": gui.App.argv,
"manifest": gui.App.manifest
}
phpwebkit.startServer(config);
});
},
startServer: function(config, callback){
@ -78,7 +81,7 @@ var phpwebkit = {
pw.changeState('Starting application...', '#00CD00');
window.location = 'http://'+host+':'+server.address().port +'/';
}).on('error', function(err) {
pw.changeState('<strong>Error: '+server.err+'</strong>', '#CD0000');
pw.changeState('<strong>Error: '+err+'</strong>', '#CD0000');
});
},
@ -93,9 +96,9 @@ var phpwebkit = {
var fs = require('fs');
fs.stat(file, function(err, stats) {
if(!err && stats.isFile()) {
return true;
callback(true);
} else {
return false;
callback(false);
}
});
}