diff --git a/src/index.ts b/src/index.ts index 1976029..d2551f6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -146,6 +146,23 @@ async function main() { }`, ) } + + const packageJsonPath = path.join(targetDirectoryPath, 'package.json') + + if (fs.existsSync(packageJsonPath)) { + const packageJson = fs.readFileSync(packageJsonPath, 'utf-8') + + const packageJsonParsed = JSON.parse(packageJson) + const newPackageJson = { + name: projectName, + ...packageJsonParsed, + } + + fs.writeFileSync( + packageJsonPath, + JSON.stringify(newPackageJson, null, 2), + ) + } console.log(chalk.green('🎉 ' + chalk.bold('Copied project files'))) console.log(chalk.gray('Get started with:'), chalk.bold(`cd ${target}`))