MCPcopy
hub / github.com/electron/forge / initDirectory

Function initDirectory

packages/api/core/src/api/init-scripts/init-directory.ts:8–28  ·  view source on GitHub ↗
(
  dir: string,
  task: ForgeListrTask<any>,
  force = false,
)

Source from the content-addressed store, hash-verified

6const d = debug('electron-forge:init:directory');
7
8export const initDirectory = async (
9 dir: string,
10 task: ForgeListrTask<any>,
11 force = false,
12): Promise<void> => {
13 d('creating directory:', dir);
14 await fs.mkdirs(dir);
15
16 const files = await fs.readdir(dir);
17 if (files.length !== 0) {
18 d(`found ${files.length} files in the directory. warning the user`);
19
20 if (force) {
21 task.output = `${logSymbols.warning} The specified path "${dir}" is not empty. "force" was set to true, so proceeding to initialize. Files may be overwritten`;
22 } else {
23 throw new Error(
24 `The specified path: "${dir}" is not empty. Please ensure it is empty before initializing a new project`,
25 );
26 }
27 }
28};

Callers 1

init.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected