From 476893fc1fc9b4124cfd7d2caf753828f61ec61c Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 5 Jul 2024 16:03:28 +1000 Subject: [PATCH] writing base file path first --- hakit/config.json | 2 +- hakit/server/routes/write-file.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hakit/config.json b/hakit/config.json index ae75c5d..282bf02 100644 --- a/hakit/config.json +++ b/hakit/config.json @@ -1,6 +1,6 @@ { "name": "Hakit", - "version": "1.0.27", + "version": "1.0.28", "slug": "hakit", "init": false, "ingress": true, diff --git a/hakit/server/routes/write-file.ts b/hakit/server/routes/write-file.ts index 48d24b7..3a6effd 100644 --- a/hakit/server/routes/write-file.ts +++ b/hakit/server/routes/write-file.ts @@ -2,6 +2,7 @@ import { Request, Response } from 'express'; import { join } from 'path'; import { writeFile as fsWriteFile } from 'fs/promises'; import { APP_DIRECTORY } from '../constants.js'; +import { ensureDirectoryExists } from '../helpers/index.js'; export async function writeFile(req: Request, res: Response) { try { @@ -12,6 +13,7 @@ export async function writeFile(req: Request, res: Response) { } const filePath = join(APP_DIRECTORY, filename); + ensureDirectoryExists(filePath, false); const fileContents = typeof content === 'string' ? content : JSON.stringify(content, null, 2); await fsWriteFile(filePath, fileContents, 'utf8');