Skip to content

Commit 53b72c2

Browse files
committed
feat: init in cwd if empty
1 parent abbd34d commit 53b72c2

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "shadcnext",
3-
"version": "0.1.1",
3+
"version": "0.1.7",
44
"description": "shadcn but for tailwind v4",
55
"license": "MIT",
66
"author": {

src/commands/create.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ export const create = new Command()
3131
? "yarn dlx"
3232
: "npx"
3333

34-
const tmpCwd = "shadcnext"
34+
let tmpCwd = "shadcnext"
3535

3636
try {
3737
await access("package.json", constants.F_OK)
38+
3839
const { stdout: gitignore } = await execa("grep", [
3940
tmpCwd,
4041
".gitignore",
@@ -44,13 +45,14 @@ export const create = new Command()
4445
spinner.info(`adding ${tmpCwd} to .gitignore...`)
4546
await appendFile(".gitignore", `\n${tmpCwd}/\n`)
4647
}
48+
49+
await execa("rm", ["-rf", tmpCwd])
50+
await execa("mkdir", ["-p", tmpCwd])
4751
} catch {
48-
spinner.info("new project detected.")
52+
const { stdout: ls } = await execa("ls", ["-A"])
53+
if (!ls) tmpCwd = "."
4954
}
5055

51-
await execa("rm", ["-rf", tmpCwd])
52-
await execa("mkdir", ["-p", tmpCwd])
53-
5456
const execaOpts = { cwd: tmpCwd }
5557
spinner.start("creating next.js project...")
5658
await execa(
@@ -83,7 +85,7 @@ export const create = new Command()
8385
await execa(pm.execute, ["@tailwindcss/upgrade@next", "--force"], execaOpts)
8486
spinner.succeed("tailwindcss upgraded to v4.")
8587

86-
const cleanup = [".git", "node_modules"]
88+
const cleanup = ["node_modules"]
8789

8890
spinner.start("cleaning up...")
8991
await execa("rm", ["-rf", ...cleanup], execaOpts)

tsup.config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { defineConfig } from "tsup"
22

33
export default defineConfig({
44
clean: true,
5-
dts: true,
5+
dts: false,
66
entry: ["src/index.ts"],
7-
format: ["cjs", "esm"],
7+
format: ["esm"],
88
minify: true,
99
outDir: "dist",
1010
sourcemap: true,

0 commit comments

Comments
 (0)