Solus Linux detection

This commit is contained in:
Scott E. Graves
2019-04-07 02:56:37 -05:00
parent 0e58e9fa65
commit 978e5d0415
5 changed files with 81 additions and 5 deletions

View File

@@ -11,6 +11,10 @@ const helpers = require('./helpers');
const fs = require('fs');
const unzip = require('unzipper');
const AutoLaunch = require('auto-launch');
require.extensions['.sh'] = function (module, filename) {
module.exports = fs.readFileSync(filename, 'utf8');
};
const detectScript = require('./public/detect_linux.sh');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
@@ -577,9 +581,27 @@ ipcMain.on(Constants.IPC_Get_Config_Template, (event, data) => {
});
ipcMain.on(Constants.IPC_Get_Platform, (event) => {
event.sender.send(Constants.IPC_Get_Platform_Reply, {
data: os.platform()
});
let platform = os.platform();
if (platform === 'linux') {
fs.writeFileSync('/tmp/repertory_detect_linux.sh', detectScript);
helpers
.executeScript('/tmp/repertory_detect_linux.sh')
.then(data => {
platform = data.replace(/(\r\n|\n|\r)/gm,"");
event.sender.send(Constants.IPC_Get_Platform_Reply, {
data: platform,
});
})
.catch(() => {
event.sender.send(Constants.IPC_Get_Platform_Reply, {
data: platform,
});
});
} else {
event.sender.send(Constants.IPC_Get_Platform_Reply, {
data: platform,
});
}
});
ipcMain.on(Constants.IPC_Get_State, (event, data) => {