DEV Community

Discussion on: July 17th, 2020: What did you learn this week?

Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€ • Edited

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

"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.

Collapse
 
nickytonline profile image
Nick Taylor

Awesome!

Hackerman from Kung Fury putting on a Nintendo Power glove