Files
mygit/e2e/helpers/utils/ensure-dir.ts
T
DuckQ1u 93d1b7c3d3
Copilot Setup Steps / copilot-setup-steps (push) Has been cancelled
first commit
2026-04-22 19:51:20 +07:00

18 lines
579 B
TypeScript

import * as fs from 'fs';
import logging from '@tryghost/logging';
/** Ensure the state directory exists. */
export const ensureDir = (dirPath: string) => {
try {
fs.mkdirSync(dirPath, {recursive: true});
} catch (error) {
// Log with structured context and rethrow preserving the original error as the cause
logging.error({
message: 'Failed to ensure directory exists',
dirPath,
err: error
});
throw new Error(`failed to ensure directory ${dirPath} exists`, {cause: error as Error});
}
};