Skip to content

Commit 53981a9

Browse files
committed
compiling system now different on various platforms
1 parent 7ec7af7 commit 53981a9

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

src/js/views/compilers/Compiler.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,43 @@ const HTMLCompiler = require('./HTMLCompiler');
99
class Compiler{
1010

1111
static compile(languageName, code){
12+
13+
let platform = this.__getPlatformName();
1214

1315
let fileAddress;
1416

1517
switch(languageName.toLowerCase()){
1618
case 'html':
1719
fileAddress = this.__saveCodes(code, 'html');
18-
HTMLCompiler.compile(fileAddress)
20+
HTMLCompiler[`compile${platform}`](fileAddress)
1921
break;
2022
case 'javascript':
2123
fileAddress = this.__saveCodes(code, 'js');
22-
JSCompiler.compile(fileAddress);
24+
JSCompiler[`compile${platform}`](fileAddress);
2325
break;
2426
case 'cpp':
2527
fileAddress = this.__saveCodes(code, 'cpp');
26-
CppCompiler.compile(fileAddress);
28+
CppCompiler[`compile${platform}`](fileAddress);
2729
break;
2830

2931
}
3032

3133
}
3234

35+
static __getPlatformName(){
36+
switch(process.platform){
37+
case 'darwin':
38+
return 'Mac';
39+
break;
40+
case 'win32':
41+
return 'Win';
42+
break;
43+
case 'linux':
44+
return 'linux';
45+
break;
46+
}
47+
}
48+
3349
static __saveCodes(code, ext){
3450

3551
let time = Date.now();

src/js/views/compilers/CppCompiler.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const {
55

66
class CppCompiler {
77

8-
static compile(fileAddress) {
8+
static compileWin(fileAddress) {
99

1010
let directory = fileAddress.split('\\');
1111
directory.pop();
@@ -21,6 +21,14 @@ class CppCompiler {
2121

2222
}
2323

24+
static compileMac(){
25+
26+
}
27+
28+
static compileLinux(){
29+
30+
}
31+
2432
}
2533

2634
module.exports = CppCompiler;

src/js/views/compilers/HTMLCompiler.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@ const {
55

66
class HTMLCompiler {
77

8-
static compile(fileAddress) {
8+
static compileWin(fileAddress) {
99

1010
exec(`${fileAddress}`);
1111

1212
}
1313

14+
static compileMac(){
15+
16+
}
17+
18+
static compileLinux(){
19+
20+
}
21+
1422
}
1523

1624
module.exports = HTMLCompiler;

src/js/views/compilers/JSCompiler.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@ const {
55

66
class JSCompiler {
77

8-
static compile(fileAddress) {
8+
static compileWin(fileAddress) {
99

1010
exec(`start cmd.exe /K node ${fileAddress}`);
1111

1212
}
1313

14+
static compileMac(){
15+
16+
}
17+
18+
static compileLinux(){
19+
20+
}
21+
1422
}
1523

1624
module.exports = JSCompiler;

0 commit comments

Comments
 (0)