|
1 | 1 | #!/usr/bin/env node |
2 | 2 |
|
3 | 3 | import { copyFile, mkdir, readFile, writeFile } from 'node:fs/promises' |
| 4 | +import { existsSync } from 'node:fs' |
4 | 5 | import { resolve } from 'node:path' |
5 | 6 | import { fileURLToPath } from 'node:url' |
6 | 7 | import { Command, InvalidArgumentError } from 'commander' |
7 | | -import { intro, outro, spinner } from '@clack/prompts' |
| 8 | +import { intro, outro, spinner, log } from '@clack/prompts' |
8 | 9 | import { execa } from 'execa' |
9 | 10 | import { render } from 'ejs' |
10 | 11 |
|
@@ -144,6 +145,11 @@ async function createApp(projectName: string, options: Required<Options>) { |
144 | 145 | ) |
145 | 146 | const targetDir = resolve(process.cwd(), projectName) |
146 | 147 |
|
| 148 | + if (existsSync(targetDir)) { |
| 149 | + log.error(`Directory "${projectName}" already exists`) |
| 150 | + return |
| 151 | + } |
| 152 | + |
147 | 153 | const copyFiles = createCopyFile(targetDir) |
148 | 154 | const templateFile = createTemplateFile(projectName, options, targetDir) |
149 | 155 |
|
@@ -257,7 +263,15 @@ async function createApp(projectName: string, options: Required<Options>) { |
257 | 263 | await execa(options.packageManager, ['install'], { cwd: targetDir }) |
258 | 264 | s.stop(`Installed dependencies`) |
259 | 265 |
|
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 | +`) |
261 | 275 | } |
262 | 276 |
|
263 | 277 | program |
|
0 commit comments