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
Currently, the generator creates a workspace package.json with commands looking like this: "command:app": "cd app && npm run command"
Assume our command is simply a (not so short) way of executing git: "command": "git"
Commands without -
This works fine if you don't need to pass - arguments to the command, like: ǹpm run command:app checkout develop
executes cd app && npm run command checkout develop
executes git checkout develop
Commands with -
But if we need to pass - arguments like this: npm run command:app checkout -b new_branch
executes cd app && npm run command checkout new_branch // Note the missing -b
What happens here is that npm consumes the -b argument as one of its own, which is the intended behaviour. To tell npm to not consume the argument, but pass it to the command, you have to mark the point where arguments start with --.
So the proper way of doing this is: npm run command:app -- checkout -b new_branch
executes cd app && npm run command checkout -b new_branch // Note the existing -b, but missing --
executes git checkout new_branch // Note the missing -b
In the npm script generated by the generator, the -- is not there and therefore the cd app && npm run command treats the -b as npm argument.
The only working way would be if the generator generates: "command:app": "cd app && npm run command --" // Note the --
such that npm run command:app -- checkout -b new_branch
executes cd app && npm run command -- checkout -b new_branch
executes git checkout -b new_branch
User stories
As a user, I want to pass arguments to the actual command defined by the script in the app package.json, not the npm command in the script in the workspace package.json.
The text was updated successfully, but these errors were encountered:
Short description
Currently, the generator creates a workspace
package.json
with commands looking like this:"command:app": "cd app && npm run command"
Assume our
command
is simply a (not so short) way of executinggit
:"command": "git"
Commands without
-
This works fine if you don't need to pass
-
arguments to the command, like:ǹpm run command:app checkout develop
executes
cd app && npm run command checkout develop
executes
git checkout develop
Commands with
-
But if we need to pass
-
arguments like this:npm run command:app checkout -b new_branch
executes
cd app && npm run command checkout new_branch // Note the missing -b
What happens here is that npm consumes the
-b
argument as one of its own, which is the intended behaviour. To tell npm to not consume the argument, but pass it to the command, you have to mark the point where arguments start with--
.So the proper way of doing this is:
npm run command:app -- checkout -b new_branch
executes
cd app && npm run command checkout -b new_branch // Note the existing -b, but missing --
executes
git checkout new_branch // Note the missing -b
In the
npm script
generated by the generator, the--
is not there and therefore thecd app && npm run command
treats the-b
asnpm
argument.The only working way would be if the generator generates:
"command:app": "cd app && npm run command --" // Note the --
such that
npm run command:app -- checkout -b new_branch
executes
cd app && npm run command -- checkout -b new_branch
executes
git checkout -b new_branch
User stories
As a user, I want to pass arguments to the actual command defined by the script in the app
package.json
, not thenpm
command in the script in the workspacepackage.json
.The text was updated successfully, but these errors were encountered: