-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui-funct.js
58 lines (43 loc) · 1.63 KB
/
gui-funct.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var is = require("electron-is");
// Mac and Linux have Bash shell scripts (so the following would work)
// var child = process.spawn('child', ['-l']);
// var child = process.spawn('./test.sh');
// Win10 with WSL (Windows Subsystem for Linux) https://docs.microsoft.com/en-us/windows/wsl/install-win10
//
// Win10 with Git-Bash (windows Subsystem for Linux) https://git-scm.com/ https://git-for-windows.github.io/
//
console.log("hello");
function appendOutput(msg) { getCommandOutput().value += (msg+'\n'); };
function setStatus(msg) { getStatus().innerHTML = msg; };
function showOS() {
if (is.windows())
appendOutput("Windows Detected.")
if (is.macOS())
appendOutput("Apple OS Detected.")
if (is.linux())
appendOutput("Linux Detected.")
}
function backgroundProcess() {
const process = require('child_process'); // The power of Node.JS
showOS();
// var cmd = (is.windows()) ? 'test.bat' : './test.sh';
var cmd = (is.windows()) ? 'test.bat' : './config-miner-krypton.sh';
console.log('cmd:', cmd);
var child = process.spawn(cmd);
child.on('error', function(err) {
appendOutput('stderr: <'+err+'>' );
});
child.stdout.on('data', function (data) {
appendOutput(data);
});
child.stderr.on('data', function (data) {
appendOutput('stderr: <'+data+'>' );
});
child.on('close', function (code) {
if (code == 0)
setStatus('child process complete.');
else
setStatus('child process exited with code ' + code);
getCommandOutput().style.background = "DarkGray";
});
};