You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ghost/e2e/helpers/utils/ensure-dir.ts

18 lines
579 B

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});
}
};