Skip to content

Commit

Permalink
Project Naming and Path Resolution Enhancements (#365)
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Fiorette <47537704+arthurfiorette@users.noreply.github.com>
Co-authored-by: Arthur Fiorette <47537704+arthurfiorette@users.noreply.github.com>
  • Loading branch information
devzolo and arthurfiorette committed Apr 1, 2024
1 parent 90657e3 commit 93cccd4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/early-turkeys-deliver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kitajs/cli": patch
---

Fixed project name detection and path resolution on Windows
6 changes: 3 additions & 3 deletions packages/cli/src/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default class Create extends Command {
type: 'input',
name: 'projectName',
message: 'What is the name of your project?',
default: flags.name || process.cwd().split('/').pop()!,
default: flags.name || path.basename(process.cwd()),
when: !flags.yes,
askAnswered: true
},
Expand All @@ -82,7 +82,7 @@ export default class Create extends Command {
}
],
{
projectName: process.cwd().split('/').pop()!,
projectName: path.basename(process.cwd()),
directory: path.resolve(flags.dir || ''),
template: 'kita'
}
Expand Down Expand Up @@ -120,7 +120,7 @@ export default class Create extends Command {
// replaces package.json and reame @kitajs/template with the project name
const packageJsonPath = path.resolve(answers.directory, 'package.json');
const packageJson = JSON.parse(await fs.promises.readFile(packageJsonPath, 'utf-8'));
packageJson.name = answers.projectName;
packageJson.name = answers.projectName === '.' ? path.basename(process.cwd()) : answers.projectName;
await fs.promises.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));

const readmePath = path.resolve(answers.directory, 'README.md');
Expand Down

0 comments on commit 93cccd4

Please sign in to comment.