We're a place where coders share, stay up-to-date and grow their careers.
I learned a nice trick. I often store my scripts in package.json but when I need to add dynamism to my script such as. package.json - old
package.json - old
"publish": "yarn publish --newVersion 1.0.2"
You can use a node script to get the version and console log to get the output.
package.json - new
"publish": "yarn publish --newVersion $(node ./getNewVersion.js)"
getNewVersion.js
// Do stuff to get version console.log(newVersion)
Stdout in action using JavaScript, sweet. Pair that with $npm_package package.json variables as stdin and you have a nice workflow.
Awesome!
I learned a nice trick.
I often store my scripts in package.json but when I need to add dynamism to my script such as.
package.json - old
You can use a node script to get the version and console log to get the output.
package.json - new
getNewVersion.js
Stdout in action using JavaScript, sweet.
Pair that with $npm_package package.json variables as stdin and you have a nice workflow.
Awesome!