Skip to content

Commit

Permalink
writing base file path first
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonhochkins committed Jul 5, 2024
1 parent 6931fba commit 476893f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hakit/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Hakit",
"version": "1.0.27",
"version": "1.0.28",
"slug": "hakit",
"init": false,
"ingress": true,
Expand Down
2 changes: 2 additions & 0 deletions hakit/server/routes/write-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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');
Expand Down

0 comments on commit 476893f

Please sign in to comment.