I want to create a file in given folder from terminal using npm script. I know it works like adding custom script in scripts
object of package.json file like:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js",
"addstyle": "touch ./css/stylesheet.css"
},
and then run npm run addstyle
from terminal.
But what if I want to pass custom name for my stylesheet from terminal?
I got few options like adding $variable
in script:
"scripts": {
...
"addstyle": "touch ./css/$filename.css"
},
and then add filename before the command ie filename=homepage npm run addstyle
Is there anyway, I can append a parameter in the end with - or -- like:
npm run addstyle --filename=homepage
. ORnpm run addstyle -filename homepage
Run this command and assign the $FILE_NAME
$FILE_NAME = 'homepage' npm run addstyle
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js",
"addstyle": "touch ./css/$FILE_NAME.css"
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.