@@ -128,7 +128,7 @@ function dir(dirPath: string, spec?: string, options?: any) {
128128// fs.rmdirSync won't delete directories with files in it
129129function deleteFolderRecursive ( dirPath : string ) {
130130 if ( fs . existsSync ( dirPath ) ) {
131- fs . readdirSync ( dirPath ) . forEach ( ( file , index ) => {
131+ fs . readdirSync ( dirPath ) . forEach ( ( file ) => {
132132 const curPath = path . join ( path , file ) ;
133133 if ( fs . statSync ( curPath ) . isDirectory ( ) ) { // recurse
134134 deleteFolderRecursive ( curPath ) ;
@@ -141,7 +141,7 @@ function deleteFolderRecursive(dirPath: string) {
141141 }
142142} ;
143143
144- function writeFile ( path : string , data : any , opts : { recursive : boolean } ) {
144+ function writeFile ( path : string , data : any ) {
145145 ensureDirectoriesExist ( getDirectoryPath ( path ) ) ;
146146 fs . writeFileSync ( path , data ) ;
147147}
@@ -208,7 +208,7 @@ enum RequestType {
208208 Unknown
209209}
210210
211- function getRequestOperation ( req : http . ServerRequest , filename : string ) {
211+ function getRequestOperation ( req : http . ServerRequest ) {
212212 if ( req . method === "GET" && req . url . indexOf ( "?" ) === - 1 ) {
213213 if ( req . url . indexOf ( "." ) !== - 1 ) return RequestType . GetFile ;
214214 else return RequestType . GetDir ;
@@ -258,7 +258,7 @@ function handleRequestOperation(req: http.ServerRequest, res: http.ServerRespons
258258 break ;
259259 case RequestType . WriteFile :
260260 processPost ( req , res , ( data ) => {
261- writeFile ( reqPath , data , { recursive : true } ) ;
261+ writeFile ( reqPath , data ) ;
262262 } ) ;
263263 send ( ResponseCode . Success , res , undefined ) ;
264264 break ;
@@ -306,7 +306,7 @@ http.createServer((req: http.ServerRequest, res: http.ServerResponse) => {
306306 log ( `${ req . method } ${ req . url } ` ) ;
307307 const uri = url . parse ( req . url ) . pathname ;
308308 const reqPath = path . join ( process . cwd ( ) , uri ) ;
309- const operation = getRequestOperation ( req , reqPath ) ;
309+ const operation = getRequestOperation ( req ) ;
310310 handleRequestOperation ( req , res , operation , reqPath ) ;
311311} ) . listen ( port ) ;
312312
0 commit comments