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.
27 lines
584 B
TypeScript
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)
|
|
}
|