fix(shadcn): init with src (#4731)

* fix(shadcn): init with src

* chore: add changesets
This commit is contained in:
shadcn
2024-09-03 22:16:59 +04:00
committed by GitHub
parent 701e1160ea
commit faa7a67fb3
2 changed files with 15 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"shadcn": patch
---
fix routes for src dir

View File

@@ -1,6 +1,7 @@
import { existsSync, promises as fs } from "fs"
import path, { basename } from "path"
import { Config } from "@/src/utils/get-config"
import { getProjectInfo } from "@/src/utils/get-project-info"
import { highlighter } from "@/src/utils/highlighter"
import { logger } from "@/src/utils/logger"
import {
@@ -37,7 +38,12 @@ export async function updateFiles(
const filesCreatedSpinner = spinner(`Updating files.`, {
silent: options.silent,
})?.start()
const baseColor = await getRegistryBaseColor(config.tailwind.baseColor)
const [projectInfo, baseColor] = await Promise.all([
getProjectInfo(config.resolvedPaths.cwd),
getRegistryBaseColor(config.tailwind.baseColor),
])
const filesCreated = []
const filesUpdated = []
const filesSkipped = []
@@ -52,7 +58,9 @@ export async function updateFiles(
let filePath = path.join(targetDir, fileName)
if (file.target) {
filePath = path.join(config.resolvedPaths.cwd, file.target)
filePath = projectInfo?.isSrcDir
? path.join(config.resolvedPaths.cwd, "src", file.target)
: path.join(config.resolvedPaths.cwd, file.target)
targetDir = path.dirname(filePath)
}