Skip to content

Commit

Permalink
fix: template creation successful, package name automatically modified.
Browse files Browse the repository at this point in the history
  • Loading branch information
hacxy committed Dec 26, 2024
1 parent c4d185b commit aec92b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"build": "pnpm -F vitepress-theme-mild run build",
"build:dev": "pnpm -F create-mild-theme run build",
"demo:build": "pnpm -F demo run build",
"release": "pnpm -F vitepress-theme-mild run release",
"cli:release": "pnpm -F create-mild-theme run release",
"release": "pnpm -F vitepress-theme-mild run release && pnpm -F create-mild-theme run release",
"demo:preview": "pnpm -F demo run preview",
"prepare": "simple-git-hooks",
"commit": "git-cz"
Expand Down
8 changes: 8 additions & 0 deletions packages/create-theme/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ export async function bootstrap() {
const targetPath = path.resolve(process.cwd(), packageName);
fs.copySync(templatePath, targetPath);
fs.renameSync(path.resolve(targetPath, '_gitignore'), path.resolve(targetPath, '.gitignore'));

const pkg = JSON.parse(
fs.readFileSync(path.resolve(targetPath, 'package.json'), 'utf-8')
);
pkg.name = packageName;

fs.writeFileSync(path.resolve(targetPath, 'package.json'), `${JSON.stringify(pkg, null, 2)}\n`);

console.log(`\ncd ${targetPath}\nnpm run install\nnpm run dev`);
}

Expand Down

0 comments on commit aec92b4

Please sign in to comment.