2017-07-02 11:22:10 -05:00
|
|
|
const Application = require('spectron').Application;
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
class App {
|
|
|
|
|
|
|
|
constructor(options) {
|
|
|
|
|
|
|
|
this.options = options;
|
|
|
|
|
2017-07-06 06:36:16 -05:00
|
|
|
if (!this.options.path) {
|
2017-07-02 11:22:10 -05:00
|
|
|
this.options.path = App.getAppPath();
|
2017-07-06 04:39:50 -05:00
|
|
|
this.options.args = [path.join(__dirname, '..', '..', 'js/main.js')];
|
2017-07-02 11:22:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
this.app = new Application(this.options);
|
|
|
|
}
|
|
|
|
|
|
|
|
startApplication() {
|
2017-07-06 06:36:16 -05:00
|
|
|
return this.app.start().then((app) => {
|
2017-07-06 04:39:50 -05:00
|
|
|
return app;
|
|
|
|
}).catch((err) => {
|
|
|
|
console.log(err);
|
2017-07-02 11:22:10 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
static getAppPath() {
|
2017-07-06 04:39:50 -05:00
|
|
|
let electronPath = path.join(__dirname, '..', '..', 'node_modules', '.bin', 'electron');
|
2017-07-02 11:22:10 -05:00
|
|
|
if (process.platform === 'win32') {
|
|
|
|
electronPath += '.cmd';
|
|
|
|
}
|
|
|
|
return electronPath
|
|
|
|
}
|
|
|
|
|
2017-07-06 06:36:16 -05:00
|
|
|
static getTimeOut() {
|
|
|
|
return 90000
|
|
|
|
}
|
|
|
|
|
2017-07-02 11:22:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = App;
|