Skip to content

Commit

Permalink
feat: add name as projectName to cloned project template package.js…
Browse files Browse the repository at this point in the history
…on (#48)

* feat: add `name` as projectName to cloned project template package.json

* chore: remove debug console logs

* patch: added checks for writing name to package.json, if exists

* fix: minor bug fix
  • Loading branch information
BRAVO68WEB authored Jun 14, 2024
1 parent af68e24 commit 2af1771
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`))
Expand Down

0 comments on commit 2af1771

Please sign in to comment.