File tree Expand file tree Collapse file tree 4 files changed +46
-6
lines changed
Expand file tree Collapse file tree 4 files changed +46
-6
lines changed Original file line number Diff line number Diff line change @@ -9,27 +9,43 @@ const HTMLCompiler = require('./HTMLCompiler');
99class 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 ( ) ;
Original file line number Diff line number Diff line change 55
66class 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
2634module . exports = CppCompiler ;
Original file line number Diff line number Diff line change @@ -5,12 +5,20 @@ const {
55
66class 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
1624module . exports = HTMLCompiler ;
Original file line number Diff line number Diff line change @@ -5,12 +5,20 @@ const {
55
66class 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
1624module . exports = JSCompiler ;
You can’t perform that action at this time.
0 commit comments