Skip to content

Commit 64afdeb

Browse files
committed
fix: fixing messages and checking for directory
1 parent 98e2364 commit 64afdeb

File tree

3 files changed

+46
-33
lines changed

3 files changed

+46
-33
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ npx create-react-app my-app
1313
You can now run:
1414

1515
```bash
16-
npx create-tsrouter-app my-app
16+
npx create-tsrouter-app@latest my-app
1717
```
1818

1919
Instead of using:
@@ -25,7 +25,7 @@ npx create-react-app my-app --template typescript
2525
To create a SPA application using TypeScript. You can now run:
2626

2727
```bash
28-
npx create-tsrouter-app my-app --template typescript
28+
npx create-tsrouter-app@latest my-app --template typescript
2929
```
3030

3131
What you'll get is a Vite application that uses TanStack Router. All the files will still be in the same place as in CRA, but you'll get a fully functional Router setup under in `app/main.tsx`.

src/index.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env node
22

33
import { copyFile, mkdir, readFile, writeFile } from 'node:fs/promises'
4+
import { existsSync } from 'node:fs'
45
import { resolve } from 'node:path'
56
import { fileURLToPath } from 'node:url'
67
import { Command, InvalidArgumentError } from 'commander'
7-
import { intro, outro, spinner } from '@clack/prompts'
8+
import { intro, outro, spinner, log } from '@clack/prompts'
89
import { execa } from 'execa'
910
import { render } from 'ejs'
1011

@@ -144,6 +145,11 @@ async function createApp(projectName: string, options: Required<Options>) {
144145
)
145146
const targetDir = resolve(process.cwd(), projectName)
146147

148+
if (existsSync(targetDir)) {
149+
log.error(`Directory "${projectName}" already exists`)
150+
return
151+
}
152+
147153
const copyFiles = createCopyFile(targetDir)
148154
const templateFile = createTemplateFile(projectName, options, targetDir)
149155

@@ -257,7 +263,15 @@ async function createApp(projectName: string, options: Required<Options>) {
257263
await execa(options.packageManager, ['install'], { cwd: targetDir })
258264
s.stop(`Installed dependencies`)
259265

260-
outro(`Created your new TanStack app in ${targetDir}.`)
266+
outro(`Created your new TanStack app in ${targetDir}.
267+
268+
Use the following commands to start your app:
269+
270+
% cd ${projectName}
271+
% ${options.packageManager} start
272+
273+
Please read README.md for more information on testing, styling, adding routes, react-query, etc.
274+
`)
261275
}
262276

263277
program

templates/base/src/logo.svg

Lines changed: 28 additions & 29 deletions
Loading

0 commit comments

Comments
 (0)