How do I pass a parameter? When I run "yarn generate" it will make both a "-p" and a "test" directory. But it works well when I run "mkdir -p test" in bash. I tried to [-p] as well but it only creates that directory.
"scripts": {
"generate": "mkdir -p test"
}
Although I could not reproduce the issue that you mentioned (my config: node v8.11.1
and yarn v1.2.1
, latest MacOS), according to the yarn docs, you can pass the arguments to yarn
script by appending them normally, like so:
yarn generate -p test
In this case your npm (yarn) scripts config (in the package.json
, I assume) would look like
"scripts": {
"generate": "mkdir"
}
If you're using Windows, you indeed won't have the mkdir -p
flag (read this). In order to make what you want (check if the folder does not exist and if so, create one) you'd need to use some cmd commands. So your package.json will contain smth like
"scripts": {
"generate": "IF NOT EXIST test mkdir test"
}