From 5e9ac1f2e2622d114e4c160a921c08d9c5284cc1 Mon Sep 17 00:00:00 2001 From: Shai Reznik Date: Mon, 4 Nov 2024 18:51:10 +0200 Subject: [PATCH] fixed cli not checking relative global.css correctly --- .changeset/soft-snakes-sniff.md | 5 +++++ packages/cli/bin/index.ts | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 .changeset/soft-snakes-sniff.md diff --git a/.changeset/soft-snakes-sniff.md b/.changeset/soft-snakes-sniff.md new file mode 100644 index 000000000..055f24522 --- /dev/null +++ b/.changeset/soft-snakes-sniff.md @@ -0,0 +1,5 @@ +--- +"qwik-ui": patch +--- + +FIX: cli not checking relative global.css correctly diff --git a/packages/cli/bin/index.ts b/packages/cli/bin/index.ts index a0bb776ce..d48b9e884 100644 --- a/packages/cli/bin/index.ts +++ b/packages/cli/bin/index.ts @@ -37,6 +37,7 @@ import { QWIK_UI_CONFIG_FILENAME, } from '../src/_shared/config-filenames'; +import path from 'path'; import externalDeps from '../src/_shared/external-deps.json'; const COMMANDS = ['init', 'add']; @@ -162,9 +163,10 @@ async function handleInit() { if (!config.rootCssPath) { config.rootCssPath = await collectFileLocationFromUser({ message: cyan( - 'Your global css file location (where you defined your tailwind directives)', + 'The path to the global css file the tailwind directives are defined (relative to the root you specified above)', ), errorMessageName: 'Global css file', + rootDir: config.projectRoot, initialValue: 'src/global.css', }); } @@ -507,6 +509,7 @@ function parseCommands(command: CommandModule) { interface FilePromptInfo { message: string; errorMessageName: string; + rootDir: string; initialValue?: string; } @@ -517,9 +520,9 @@ async function collectFileLocationFromUser(config: FilePromptInfo) { initialValue: config.initialValue, }), ); - - if (!existsSync(filePath)) { - log.error(`${config.errorMessageName} not found at ${filePath}, want to try again?`); + const fullPath = path.join(config.rootDir, filePath); + if (!existsSync(fullPath)) { + log.error(`${config.errorMessageName} not found at ${fullPath}, want to try again?`); return collectFileLocationFromUser({ ...config, initialValue: filePath }); } return filePath;