Skip to content

Commit a7d0947

Browse files
authored
fix: don't crash if schema cache directories already exist
1 parent 40ea781 commit a7d0947

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

src/utils/schema.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function loadJsonFromURL<T>(
127127
const httpRequestOptions = options?.requestOptions ?? {};
128128
const httpGetModulePath = resolvePath(options?.getModulePath, context);
129129

130-
makeDirs(path.dirname(jsonFilePath));
130+
fs.mkdirSync(path.dirname(jsonFilePath), { recursive: true });
131131

132132
let data, timestamp;
133133
try {
@@ -211,20 +211,6 @@ function postProcess<T>(
211211
return data;
212212
}
213213

214-
/**
215-
* Make directories
216-
*/
217-
function makeDirs(dir: string) {
218-
const dirs = [dir];
219-
while (!fs.existsSync(dirs[0])) {
220-
dirs.unshift(path.dirname(dirs[0]));
221-
}
222-
dirs.shift();
223-
for (const dir of dirs) {
224-
fs.mkdirSync(dir);
225-
}
226-
}
227-
228214
/**
229215
* JSON Schema to string
230216
*/

0 commit comments

Comments
 (0)