Files
payloadcms/packages/create-payload-app/src/lib/parse-project-name.ts
Elliot DeNolf 142616e6ad chore(eslint): curly [skip-lint] (#7959)
Now enforcing curly brackets on all if statements. Includes auto-fixer.


```ts
//  Bad
if (foo) foo++;

//  Good
if (foo) {
  foo++;
}
```




Note: this did not lint the `drizzle` package or any `db-*` packages.
This will be done in the future.
2024-08-29 10:15:36 -04:00

27 lines
584 B
TypeScript

import * as p from '@clack/prompts'
import slugify from '@sindresorhus/slugify'
import type { CliArgs } from '../types.js'
export async function parseProjectName(args: CliArgs): Promise<string> {
if (args['--name']) {
return slugify(args['--name'])
}
if (args._[0]) {
return slugify(args._[0])
}
const projectName = await p.text({
message: 'Project name?',
validate: (value) => {
if (!value) {
return 'Please enter a project name.'
}
},
})
if (p.isCancel(projectName)) {
process.exit(0)
}
return slugify(projectName)
}