From 87bb639a4158245eee7d719a86bac0578a0e8923 Mon Sep 17 00:00:00 2001 From: Bryce Kalow Date: Wed, 24 Jul 2024 14:32:47 -0500 Subject: [PATCH] fix(dev-cli): Call mkdir before attempting to write the config file (#3804) --- .changeset/heavy-pillows-sparkle.md | 5 +++++ packages/dev-cli/src/commands/init.js | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/heavy-pillows-sparkle.md diff --git a/.changeset/heavy-pillows-sparkle.md b/.changeset/heavy-pillows-sparkle.md new file mode 100644 index 0000000000..8429a98493 --- /dev/null +++ b/.changeset/heavy-pillows-sparkle.md @@ -0,0 +1,5 @@ +--- +"@clerk/dev-cli": patch +--- + +Fix a bug where `clerk-dev init` would error if the config directory did not already exist. diff --git a/packages/dev-cli/src/commands/init.js b/packages/dev-cli/src/commands/init.js index 1f5440a206..f4bd6688d3 100644 --- a/packages/dev-cli/src/commands/init.js +++ b/packages/dev-cli/src/commands/init.js @@ -1,6 +1,6 @@ import { spawn } from 'node:child_process'; -import { writeFile } from 'node:fs/promises'; -import { join } from 'node:path'; +import { mkdir, writeFile } from 'node:fs/promises'; +import { dirname, join } from 'node:path'; import { CONFIG_FILE } from '../utils/getConfiguration.js'; import { getCLIRoot } from '../utils/getMonorepoRoot.js'; @@ -26,6 +26,8 @@ export async function init() { }, }; + await mkdir(dirname(CONFIG_FILE), { recursive: true }); + await writeFile(CONFIG_FILE, JSON.stringify(configuration, null, 2), 'utf-8'); if (process.env.VISUAL) {