Skip to content

Commit

Permalink
fix(shadcn): init with src (#4731)
Browse files Browse the repository at this point in the history
* fix(shadcn): init with src

* chore: add changesets
  • Loading branch information
shadcn authored Sep 3, 2024
1 parent 701e116 commit faa7a67
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/odd-swans-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"shadcn": patch
---

fix routes for src dir
12 changes: 10 additions & 2 deletions packages/shadcn/src/utils/updaters/update-files.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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 = []
Expand All @@ -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)
}

Expand Down

0 comments on commit faa7a67

Please sign in to comment.