create-bz-mern-app
Version:
CLI to scaffold a fullstack React + Node.js app with Google login and JWT auth
34 lines (27 loc) ⢠878 B
JavaScript
const fs = require("fs-extra");
const path = require("path");
const targetDir = process.cwd();
const templateDir = path.join(__dirname, "template");
(async () => {
try {
const templateFiles = await fs.readdir(templateDir);
for (const file of templateFiles) {
const destPath = path.join(targetDir, file);
if (fs.existsSync(destPath)) {
console.error(`ā File or directory '${file}' already exists in the current directory`);
process.exit(1);
}
}
await fs.copy(templateDir, targetDir);
console.log(`ā
Template files copied to current directory!`);
console.log(`ā
Update the environment variables and you are ready to run the project!`);
console.log(`
š Next steps:
npm run dev
`);
} catch (err) {
console.error("ā Error:", err.message);
process.exit(1);
}
})();