Created
June 22, 2022 23:56
-
-
Save purplecabbage/4fafaa0cae599c0cf4fa165a211762f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setPackageBin (packageBinName, packageJson) { | |
if (packageBinName && packageBinName.trim().length > 0) { | |
const [key, value] = Object.entries(packageJson.bin)[0] | |
packageJson.bin = { [packageBinName] : value } | |
} | |
return packageJson | |
} | |
let testPackages = [ | |
{ bin: { zoom: 'some value 1' } }, | |
{ bin: { zoom2: 'some value 2' } }, | |
{ bin: { zoom3: 'some value 3' } }, | |
{ bin: { zoom4: 'some value 4', zoom5: 'somevalue5' } }, | |
] | |
console.log('Before: ', testPackages) | |
for (const val of testPackages) { | |
console.log('processing ; ', val) | |
let result = setPackageBin('nexty-next', val) | |
console.log('resut = ', result) | |
console.log('---') | |
} | |
console.log('After: ', testPackages) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment