diff --git a/change-package-name.js b/change-package-name.js deleted file mode 100644 index 982966e9..00000000 --- a/change-package-name.js +++ /dev/null @@ -1,24 +0,0 @@ -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() \ No newline at end of file diff --git a/scripts/json-updater.js b/scripts/json-updater.js new file mode 100644 index 00000000..ca32109c --- /dev/null +++ b/scripts/json-updater.js @@ -0,0 +1,31 @@ +/* Modify keys in the package.json file +Usage: `libMVRgdtf$ >node scripts/json-updater.js --key value --key2 value2 ...` +Example: `libMVRgdtf$ >node scripts/json-updater.js --name @mvr/lib-windows` +*/ + +const fs = require('fs'); +const path = require('path'); + +class PackageJSONManager { + constructor() { + this.filePath = path.join('package.json') + this.packageJson = JSON.parse(fs.readFileSync(this.filePath, 'utf8')); + } + + updateKey(key, value) { + if (!key || !value) return; + this.packageJson[key] = value; + } + + save() { + fs.writeFileSync(this.filePath, 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()