You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes it comes pretty handy not to write long commands again, thanks to scripts it's easy. Unfortunately, sometimes you have commands that are long but need extra information to work, for which you don't want to write a script each. I ran into this several times a day. There is pnpm <command> -- <passed-along> but this does not work in all cases like if you have something quoted.
Let's take a (basic) real-world example in a nx Monorepo with Capacitor where nx runs a capacitor command:
"sync": "nx run project:cap --cmd='sync'"
This does a few things like copying dist files to native directories and updates native dependencies. This command can take a few seconds. We can pass "ios" or "android" to run sync only for the specified target, which makes the execution faster.
Now in npm scripts I would need two scripts "sync-ios" and "sync-android". What I would like to have is something like in bash "$@" so I can choose where additional args and flags get injected. So I could write the following:
"sync": "nx run project:cap --cmd=\"sync $@\" --no-open"
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Sometimes it comes pretty handy not to write long commands again, thanks to scripts it's easy. Unfortunately, sometimes you have commands that are long but need extra information to work, for which you don't want to write a script each. I ran into this several times a day. There is
pnpm <command> -- <passed-along>
but this does not work in all cases like if you have something quoted.Let's take a (basic) real-world example in a nx Monorepo with Capacitor where nx runs a capacitor command:
This does a few things like copying dist files to native directories and updates native dependencies. This command can take a few seconds. We can pass "ios" or "android" to run sync only for the specified target, which makes the execution faster.
Now in npm scripts I would need two scripts "sync-ios" and "sync-android". What I would like to have is something like in bash "$@" so I can choose where additional args and flags get injected. So I could write the following:
And run:
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions