myoperator-ui 0.0.29 → 0.0.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +18 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -604,15 +604,28 @@ export function cn(...inputs: ClassValue[]) {
|
|
|
604
604
|
} else {
|
|
605
605
|
const existingUtils = await fs2.readFile(utilsPath, "utf-8");
|
|
606
606
|
if (!existingUtils.includes("export function cn") && !existingUtils.includes("export const cn")) {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
607
|
+
let updatedContent = existingUtils;
|
|
608
|
+
const hasClsxImport = existingUtils.includes('from "clsx"') || existingUtils.includes("from 'clsx'");
|
|
609
|
+
const hasTwMergeImport = existingUtils.includes('from "tailwind-merge"') || existingUtils.includes("from 'tailwind-merge'");
|
|
610
|
+
let importsToAdd = "";
|
|
611
|
+
if (!hasClsxImport) {
|
|
612
|
+
importsToAdd += `import { type ClassValue, clsx } from "clsx"
|
|
613
|
+
`;
|
|
614
|
+
}
|
|
615
|
+
if (!hasTwMergeImport) {
|
|
616
|
+
importsToAdd += `import { twMerge } from "tailwind-merge"
|
|
617
|
+
`;
|
|
618
|
+
}
|
|
619
|
+
if (importsToAdd) {
|
|
620
|
+
updatedContent = importsToAdd + updatedContent;
|
|
621
|
+
}
|
|
622
|
+
const cnFunction = `
|
|
611
623
|
export function cn(...inputs: ClassValue[]) {
|
|
612
624
|
return twMerge(clsx(inputs))
|
|
613
625
|
}
|
|
614
626
|
`;
|
|
615
|
-
|
|
627
|
+
updatedContent = updatedContent.trimEnd() + "\n" + cnFunction;
|
|
628
|
+
await fs2.writeFile(utilsPath, updatedContent);
|
|
616
629
|
utilsUpdated = true;
|
|
617
630
|
}
|
|
618
631
|
}
|