Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions internal/tailwind-config/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Config } from 'tailwindcss';

import fs from 'node:fs';
import path from 'node:path';

import { addDynamicIconSelectors } from '@iconify/tailwind';
Expand All @@ -11,15 +12,23 @@ import { enterAnimationPlugin } from './plugins/entry';

// import defaultTheme from 'tailwindcss/defaultTheme';

const { packages } = getPackagesSync(process.cwd());
// 只有在当前工作目录(process.cwd)能找到 package.json 时,才调用 getPackagesSync
let packages: Array<any> = [];
try {
const pkgJsonPath = path.join(process.cwd(), 'package.json');
// 当 Prettier/编辑器在 VS Code 可执行目录运行时(没有 package.json),退回空列表
packages = fs.existsSync(pkgJsonPath)
? getPackagesSync(process.cwd()).packages
: [];
} catch {
console.log('test?');
packages = [];
}
Comment on lines +23 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Remove debug statement and add proper error logging.

Two issues with the catch block:

  1. Critical: Line 24 contains console.log('test?') which appears to be debug/placeholder code that must be removed before merging to production.

  2. Major: The catch block silently swallows errors without proper logging. If getPackagesSync fails for reasons other than a missing package.json, developers will have no visibility into what went wrong.

Apply this diff to fix both issues:

 } catch (error) {
-  console.log('test?');
+  console.warn('Failed to discover workspace packages:', error);
   packages = [];
 }

This provides meaningful diagnostic information while still gracefully falling back to an empty array.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch {
console.log('test?');
packages = [];
}
} catch (error) {
console.warn('Failed to discover workspace packages:', error);
packages = [];
}
🤖 Prompt for AI Agents
In internal/tailwind-config/src/index.ts around lines 23–26, remove the debug
console.log('test?') and replace the empty catch with a parameterized catch that
logs the failure before falling back to an empty packages array; specifically,
catch the error into a variable and call console.error (or the project's logger)
with a clear message like "Failed to get packages" plus the error details, then
set packages = [] so the code still recovers gracefully.


const tailwindPackages: string[] = [];

packages.forEach((pkg) => {
// apps目录下和 @vben-core/tailwind-ui 包需要使用到 tailwindcss ui
// if (fs.existsSync(path.join(pkg.dir, 'tailwind.config.mjs'))) {
tailwindPackages.push(pkg.dir);
// }
});

const shadcnUiColors = {
Expand Down
Loading