From 0fea32c204cbff1b8f81e5001b1cbb88b6aa07bb Mon Sep 17 00:00:00 2001 From: mrfry Date: Tue, 2 May 2023 08:09:42 +0200 Subject: [PATCH] write file fix --- src/utils/utils.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index faa882a..3111293 100755 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -48,6 +48,7 @@ import logger from '../utils/logger' import { paths } from './files' import { Request } from '../types/basicTypes' +import path from 'node:path' interface URLFormatOptions { pathname?: string @@ -151,12 +152,8 @@ function WatchFile(file: string, callback: Function): void { } } -function createDirsForFile(path: string): void { - let pathPart = path - if (pathPart.endsWith('/')) { - pathPart = pathPart.slice(0, -1) - } - pathPart = path.split('/').slice(0, -1).join('/') +function createDirsForFile(dir: string): void { + const pathPart = path.dirname(dir) CreatePath(pathPart) }