Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCarlos Vieira
Courses Plus Student 1,345 PointsDoes npm tasks accept variables?
For instance, imagine I want to build a task to remove all the content of a folder:
"remove": "rm <folder>/*"
Then, on the command line do something like
npm run remove <folder>
1 Answer
Tom Geraghty
24,174 PointsYes.
See https://docs.npmjs.com/cli/run-script
As of npm@2.0.0, you can use custom arguments when executing scripts. The special option -- is used by getopt to delimit the end of the options. npm will pass all the arguments after the -- directly to your script:
npm run test -- --<your arguments>
GREGORY ASSASIE
3,898 PointsGREGORY ASSASIE
3,898 PointsI believe you can only use NODE environment variables. Look up one of those task runners (gulp, grunt). You can automates tasks like that easily. i recommend gulp but if you like configuration, look up grunt.