From a7d094778d68d039c6dbfab52f02114cbdf4e846 Mon Sep 17 00:00:00 2001 From: Anton Stoychev Date: Fri, 6 Dec 2024 08:04:20 +0200 Subject: [PATCH 1/2] fix: don't crash if schema cache directories already exist --- src/utils/schema.ts | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/utils/schema.ts b/src/utils/schema.ts index 9075ca0f..2c9ca01c 100644 --- a/src/utils/schema.ts +++ b/src/utils/schema.ts @@ -127,7 +127,7 @@ function loadJsonFromURL( const httpRequestOptions = options?.requestOptions ?? {}; const httpGetModulePath = resolvePath(options?.getModulePath, context); - makeDirs(path.dirname(jsonFilePath)); + fs.mkdirSync(path.dirname(jsonFilePath), { recursive: true }); let data, timestamp; try { @@ -211,20 +211,6 @@ function postProcess( return data; } -/** - * Make directories - */ -function makeDirs(dir: string) { - const dirs = [dir]; - while (!fs.existsSync(dirs[0])) { - dirs.unshift(path.dirname(dirs[0])); - } - dirs.shift(); - for (const dir of dirs) { - fs.mkdirSync(dir); - } -} - /** * JSON Schema to string */ From 20ca5743f8ed756e086e292b28fdbc3625e306c6 Mon Sep 17 00:00:00 2001 From: Yosuke Ota Date: Fri, 6 Dec 2024 15:25:03 +0900 Subject: [PATCH 2/2] Create five-dodos-cheat.md --- .changeset/five-dodos-cheat.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/five-dodos-cheat.md diff --git a/.changeset/five-dodos-cheat.md b/.changeset/five-dodos-cheat.md new file mode 100644 index 00000000..39b81f39 --- /dev/null +++ b/.changeset/five-dodos-cheat.md @@ -0,0 +1,5 @@ +--- +"eslint-plugin-json-schema-validator": patch +--- + +fix: don't crash if schema cache directories already exist