-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for ~ in target specification (#4848)
* Adding support for ~ in target specification * test(shadcn): add a test for srcDir false * chore: changeset --------- Co-authored-by: shadcn <[email protected]>
- Loading branch information
Showing
3 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"shadcn": patch | ||
--- | ||
|
||
add support for ~ dir in target path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { describe, expect, test } from "vitest" | ||
|
||
import { resolveTargetDir } from "../../../src/utils/updaters/update-files" | ||
|
||
describe("resolveTargetDir", () => { | ||
test("should handle a home target without a src directory", () => { | ||
const targetDir = resolveTargetDir( | ||
{ | ||
isSrcDir: false, | ||
}, | ||
{ | ||
resolvedPaths: { | ||
cwd: "/foo/bar", | ||
}, | ||
}, | ||
"~/.env" | ||
) | ||
expect(targetDir).toBe("/foo/bar/.env") | ||
}) | ||
|
||
test("should handle a home target even with a src directory", () => { | ||
const targetDir = resolveTargetDir( | ||
{ | ||
isSrcDir: true, | ||
}, | ||
{ | ||
resolvedPaths: { | ||
cwd: "/foo/bar", | ||
}, | ||
}, | ||
"~/.env" | ||
) | ||
expect(targetDir).toBe("/foo/bar/.env") | ||
}) | ||
|
||
test("should handle a simple target", () => { | ||
const targetDir = resolveTargetDir( | ||
{ | ||
isSrcDir: false, | ||
}, | ||
{ | ||
resolvedPaths: { | ||
cwd: "/foo/bar", | ||
}, | ||
}, | ||
"./components/ui/button.tsx" | ||
) | ||
expect(targetDir).toBe("/foo/bar/components/ui/button.tsx") | ||
}) | ||
|
||
test("should handle a simple target with src directory", () => { | ||
const targetDir = resolveTargetDir( | ||
{ | ||
isSrcDir: true, | ||
}, | ||
{ | ||
resolvedPaths: { | ||
cwd: "/foo/bar", | ||
}, | ||
}, | ||
"./components/ui/button.tsx" | ||
) | ||
expect(targetDir).toBe("/foo/bar/src/components/ui/button.tsx") | ||
}) | ||
}) |