MCPcopy
hub / github.com/angular/angular / ensureDirExists

Function ensureDirExists

packages/compiler-cli/test/test_support.ts:78–88  ·  view source on GitHub ↗
(absolutePathToDir: string)

Source from the content-addressed store, hash-verified

76 };
77
78 function ensureDirExists(absolutePathToDir: string) {
79 if (fs.existsSync(absolutePathToDir)) {
80 if (!fs.statSync(absolutePathToDir).isDirectory()) {
81 throw new Error(`'${absolutePathToDir}' exists and is not a directory.`);
82 }
83 } else {
84 const parentDir = path.dirname(absolutePathToDir);
85 ensureDirExists(parentDir);
86 fs.mkdirSync(absolutePathToDir);
87 }
88 }
89
90 function write(fileName: string, content: string) {
91 const absolutePathToFile = path.resolve(basePath, fileName);

Callers 1

writeFunction · 0.85

Calls 2

isDirectoryMethod · 0.65
dirnameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…