@@ -128,7 +128,7 @@ function dir(dirPath: string, spec?: string, options?: any) {
128
128
// fs.rmdirSync won't delete directories with files in it
129
129
function deleteFolderRecursive ( dirPath : string ) {
130
130
if ( fs . existsSync ( dirPath ) ) {
131
- fs . readdirSync ( dirPath ) . forEach ( ( file , index ) => {
131
+ fs . readdirSync ( dirPath ) . forEach ( ( file ) => {
132
132
const curPath = path . join ( path , file ) ;
133
133
if ( fs . statSync ( curPath ) . isDirectory ( ) ) { // recurse
134
134
deleteFolderRecursive ( curPath ) ;
@@ -141,7 +141,7 @@ function deleteFolderRecursive(dirPath: string) {
141
141
}
142
142
} ;
143
143
144
- function writeFile ( path : string , data : any , opts : { recursive : boolean } ) {
144
+ function writeFile ( path : string , data : any ) {
145
145
ensureDirectoriesExist ( getDirectoryPath ( path ) ) ;
146
146
fs . writeFileSync ( path , data ) ;
147
147
}
@@ -208,7 +208,7 @@ enum RequestType {
208
208
Unknown
209
209
}
210
210
211
- function getRequestOperation ( req : http . ServerRequest , filename : string ) {
211
+ function getRequestOperation ( req : http . ServerRequest ) {
212
212
if ( req . method === "GET" && req . url . indexOf ( "?" ) === - 1 ) {
213
213
if ( req . url . indexOf ( "." ) !== - 1 ) return RequestType . GetFile ;
214
214
else return RequestType . GetDir ;
@@ -258,7 +258,7 @@ function handleRequestOperation(req: http.ServerRequest, res: http.ServerRespons
258
258
break ;
259
259
case RequestType . WriteFile :
260
260
processPost ( req , res , ( data ) => {
261
- writeFile ( reqPath , data , { recursive : true } ) ;
261
+ writeFile ( reqPath , data ) ;
262
262
} ) ;
263
263
send ( ResponseCode . Success , res , undefined ) ;
264
264
break ;
@@ -306,7 +306,7 @@ http.createServer((req: http.ServerRequest, res: http.ServerResponse) => {
306
306
log ( `${ req . method } ${ req . url } ` ) ;
307
307
const uri = url . parse ( req . url ) . pathname ;
308
308
const reqPath = path . join ( process . cwd ( ) , uri ) ;
309
- const operation = getRequestOperation ( req , reqPath ) ;
309
+ const operation = getRequestOperation ( req ) ;
310
310
handleRequestOperation ( req , res , operation , reqPath ) ;
311
311
} ) . listen ( port ) ;
312
312
0 commit comments