Skip to content

Commit 0830dcb

Browse files
antitoxicota-meshi
andauthored
fix: don't crash if schema cache directories already exist (#365)
* fix: don't crash if schema cache directories already exist * Create five-dodos-cheat.md --------- Co-authored-by: Yosuke Ota <[email protected]>
1 parent 40ea781 commit 0830dcb

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

.changeset/five-dodos-cheat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"eslint-plugin-json-schema-validator": patch
3+
---
4+
5+
fix: don't crash if schema cache directories already exist

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)