@@ -7,8 +7,8 @@ const ROOT_DIR = `${process.cwd()}`;
7
7
const SOURCE_DIR = path . join ( ROOT_DIR , 'executor' ) ;
8
8
const TARGET_DIR = `/app/codes` ;
9
9
const IMAGE_NAME = 'executor:1.0' ;
10
- // const VOL_NAME = `my_vol`;
11
- const VOL_NAME = SOURCE_DIR ;
10
+ const VOL_NAME = `my_vol` ;
11
+ // const VOL_NAME = SOURCE_DIR;
12
12
13
13
class CodeService {
14
14
async execute ( code , input , lang , id ) {
@@ -77,6 +77,10 @@ class CodeService {
77
77
fileName += '.java' ;
78
78
break ;
79
79
}
80
+ case 'c' : {
81
+ fileName += '.c' ;
82
+ break ;
83
+ }
80
84
default : {
81
85
throw { message : 'Invalid language' } ;
82
86
}
@@ -114,6 +118,10 @@ class CodeService {
114
118
command = `cd ${ TARGET_DIR } && javac ${ file } && java Input < ${ input } ` ;
115
119
break ;
116
120
}
121
+ case 'c' : {
122
+ command = `cd ${ TARGET_DIR } && gcc -o ${ id } ${ file } && ./${ id } < ${ input } ` ;
123
+ break ;
124
+ }
117
125
default : {
118
126
throw { message : 'Invalid language' } ;
119
127
}
@@ -157,9 +165,9 @@ class CodeService {
157
165
if ( err ) throw { message : err } ;
158
166
} ) ;
159
167
}
160
- if ( lang == 'c++' ) {
168
+ if ( lang == 'c++' || lang == 'c' ) {
161
169
fs . unlinkSync ( path . join ( SOURCE_DIR , id ) , err => {
162
- if ( err ) throw { message : err } ;
170
+ if ( err ) throw err ;
163
171
} ) ;
164
172
}
165
173
if ( lang == 'java' ) {
0 commit comments