mirror of
https://github.com/directus/directus.git
synced 2026-02-13 04:54:57 -05:00
20 lines
531 B
TypeScript
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`);
|
|
}
|
|
}
|
|
}
|