2015-09-11 16:25:45 +02:00
|
|
|
var Util = require('../../util');
|
2015-10-29 16:36:44 +01:00
|
|
|
var logger = Util.Logger;
|
2017-07-24 14:58:05 +02:00
|
|
|
var LoggerStream = Util.LoggerStream;
|
|
|
|
var remote = require('electron').remote;
|
2015-09-03 15:50:23 +02:00
|
|
|
|
2015-09-04 12:10:08 +02:00
|
|
|
var RUN_APP = exports.RUN_APP = 'RUN_APP';
|
|
|
|
var RUN_APP_SUCCESS = exports.RUN_APP_SUCCESS = 'RUN_APP_SUCCESS';
|
|
|
|
var RUN_APP_FAILED = exports.RUN_APP_FAILED = 'RUN_APP_FAILED';
|
|
|
|
|
|
|
|
exports.runApp = function(execPath) {
|
|
|
|
|
|
|
|
return function(dispatch, getState) {
|
|
|
|
|
2015-10-29 16:36:44 +01:00
|
|
|
logger.info('Launching app "%s"', execPath);
|
|
|
|
|
2015-09-04 12:10:08 +02:00
|
|
|
dispatch({ type: RUN_APP, execPath: execPath });
|
|
|
|
|
2017-07-24 14:58:05 +02:00
|
|
|
var opts = {
|
|
|
|
clearFreeDesktopFlags: true,
|
|
|
|
stdout: process.stdout,
|
|
|
|
stderr: process.stderr
|
|
|
|
}
|
|
|
|
|
|
|
|
return Util.System.runApp(execPath, opts)
|
2015-09-04 12:10:08 +02:00
|
|
|
.then(function() {
|
|
|
|
dispatch({ type: RUN_APP_SUCCESS, execPath: execPath });
|
2015-11-05 11:41:51 +01:00
|
|
|
// Hypothetical fix
|
|
|
|
var win = remote.getCurrentWindow();
|
|
|
|
win.show();
|
2015-09-04 12:10:08 +02:00
|
|
|
return execPath;
|
|
|
|
})
|
|
|
|
.catch(function(err) {
|
|
|
|
dispatch({ type: RUN_APP_FAILED, error: err });
|
2015-11-05 11:41:51 +01:00
|
|
|
// Hypothetical fix
|
|
|
|
var win = remote.getCurrentWindow();
|
|
|
|
win.show();
|
2015-09-04 12:10:08 +02:00
|
|
|
return err;
|
|
|
|
})
|
|
|
|
;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-09-03 15:50:23 +02:00
|
|
|
};
|