UNPKG

namastejs

Version:

A spiritual greeting from your JavaScript code. Because every function deserves a 'Namaste šŸ™'

43 lines (34 loc) • 1.34 kB
const { execSync } = require("child_process"); function parseArgs(args) { const result = {}; args.forEach(arg => { const [key, value] = arg.split("="); if (key.startsWith("--") && value) { result[key.replace("--", "")] = value; } }); return result; } function updateCLI(rawArgs) { const args = parseArgs(rawArgs); const myBranch = args.my; const fromBranch = args.from; if (!myBranch || !fromBranch) { console.log("āŒ Please provide both --my and --from branches."); console.log("Usage: npx namastejs update --my=your-branch --from=source-branch"); return; } try { console.clear(); console.log(`šŸ”„ Switching to '${fromBranch}' and pulling latest...`); execSync(`git checkout ${fromBranch}`, { stdio: "inherit" }); execSync(`git pull origin ${fromBranch}`, { stdio: "inherit" }); console.log(`\nšŸ”€ Switching to '${myBranch}' and merging '${fromBranch}'...`); execSync(`git checkout ${myBranch}`, { stdio: "inherit" }); execSync(`git merge ${fromBranch}`, { stdio: "inherit" }); console.log(`\nāœ… Update complete. '${fromBranch}' merged into '${myBranch}'. Namaste šŸ™`); } catch (err) { console.error("āŒ Something went wrong during the Git process."); } } module.exports = { updateCLI };