Files
directus/packages/utils/node/ensure-extension-dirs.ts
rijkvanzanten 37658802b7 One more
2023-04-14 17:30:56 -04:00

20 lines
531 B
TypeScript

import type { NestedExtensionType } from '@directus/types';
import fse from 'fs-extra';
import path from 'path';
import { pluralize } from './pluralize.js';
export async function ensureExtensionDirs(
extensionsPath: string,
types: readonly NestedExtensionType[]
): Promise<void> {
for (const extensionType of types) {
const dirPath = path.resolve(extensionsPath, pluralize(extensionType));
try {
await fse.ensureDir(dirPath);
} catch {
throw new Error(`Extension folder "${dirPath}" couldn't be opened`);
}
}
}