MCPcopy
hub / github.com/nukeop/nuclear / ensureDir

Function ensureDir

packages/player/src/utils/path.ts:6–31  ·  view source on GitHub ↗
(
  dir: string,
  baseDir: BaseDirectory = BaseDirectory.AppData,
)

Source from the content-addressed store, hash-verified

4import { reportError, resolveErrorMessage } from './logging';
5
6export const ensureDir = async (
7 dir: string,
8 baseDir: BaseDirectory = BaseDirectory.AppData,
9) => {
10 try {
11 const present = await exists(dir, { baseDir });
12 if (!present) {
13 try {
14 await mkdir(dir, {
15 recursive: true,
16 baseDir,
17 });
18 } catch (error) {
19 await reportError('fs', {
20 userMessage: `Failed to create directory ${dir}`,
21 error,
22 });
23 }
24 }
25 } catch (error) {
26 Logger.fs.error(
27 `fs.exists failed for ${dir}: ${resolveErrorMessage(error)}`,
28 );
29 }
30 return dir;
31};

Callers 5

ensureThemesDirFunction · 0.90
ensureStoreThemesDirFunction · 0.90
ensurePluginsDirFunction · 0.90
getDownloadsDirFunction · 0.90
useInstallThemeFunction · 0.90

Calls 3

reportErrorFunction · 0.90
resolveErrorMessageFunction · 0.90
errorMethod · 0.80

Tested by

no test coverage detected