Skip to content

Commit

Permalink
Package json update keys script
Browse files Browse the repository at this point in the history
  • Loading branch information
SimeonRolev committed Oct 7, 2024
1 parent dc5c090 commit cb6ece5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
package-lock=false
@mvrdevelopment:registry=https://npm.pkg.github.com
24 changes: 24 additions & 0 deletions change-package-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const fs = require('fs');

class PackageJSONManager {
constructor() {
this.packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
}

updateKey(key, value) {
if (!key || !value) return;
this.packageJson[key] = value;
}

save() {
fs.writeFileSync('package.json', JSON.stringify(this.packageJson, null, 4) + '\n');
}
}

const manager = new PackageJSONManager();
process.argv.forEach((key, index) => {
if (key.startsWith('--')) {
manager.updateKey(key.substring(2), process.argv[index + 1]);
}
})
manager.save()

0 comments on commit cb6ece5

Please sign in to comment.