Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append '--' to the created npm commands in workspace package.json #354

Open
puehringer opened this issue Mar 26, 2020 · 0 comments
Open
Assignees

Comments

@puehringer
Copy link
Contributor

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 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants