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; var pw = this;
process.on('uncaughtException', function(err){ 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'); 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; var path = gui.App.manifest.phpwebkit.path;
if(path === undefined || path == "") { if(path === undefined || path == "") {
path = './application'; path = './application';
@ -48,6 +45,11 @@ var phpwebkit = {
port = 0; port = 0;
} }
this.fileExists(bin, function(result){
if(result === false) {
bin = 'php-cgi';
}
var config = { var config = {
"path": path, "path": path,
"bin": bin, "bin": bin,
@ -57,7 +59,8 @@ var phpwebkit = {
"manifest": gui.App.manifest "manifest": gui.App.manifest
} }
this.startServer(config); phpwebkit.startServer(config);
});
}, },
startServer: function(config, callback){ startServer: function(config, callback){
@ -78,7 +81,7 @@ var phpwebkit = {
pw.changeState('Starting application...', '#00CD00'); pw.changeState('Starting application...', '#00CD00');
window.location = 'http://'+host+':'+server.address().port +'/'; window.location = 'http://'+host+':'+server.address().port +'/';
}).on('error', function(err) { }).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'); var fs = require('fs');
fs.stat(file, function(err, stats) { fs.stat(file, function(err, stats) {
if(!err && stats.isFile()) { if(!err && stats.isFile()) {
return true; callback(true);
} else { } else {
return false; callback(false);
} }
}); });
} }