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
Use shell option when spawning lerna exec
#761
Conversation
Can you add an integration test for this? |
@@ -38,6 +38,7 @@ export default class ExecCommand extends Command { | |||
getOpts(pkg) { | |||
return { | |||
cwd: pkg.location, | |||
shell: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this property is necessary, as execa is handling this for us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lerna exec -- npm view \$LERNA_PACKAGE_NAME
works perfectly fine as-is on master
, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was broken with spawn...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm view
reports on the package in the current directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, I just reproduced it locally.
test.concurrent("$LERNA_PACKAGE_NAME", () => {
return initFixture("ExecCommand/basic").then((cwd) => {
const args = [
"exec",
"echo",
"\$LERNA_PACKAGE_NAME",
"--concurrency=1",
];
return execa(LERNA_BIN, args, { cwd }).then((result) => {
expect(result.stdout).toMatchSnapshot("echo: $LERNA_PACKAGE_NAME");
});
});
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, it doesn't seem to matter if you pass "$LERNA_PACKAGE_NAME",
or "\$LERNA_PACKAGE_NAME",
in the integration test, but it certainly matters in the CLI command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The integration test isn't evaluating the variables before sending the arguments to lerna.
Added an integration test that fails on the master branch and passes with the fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jwb!
oh noes Windows :P |
How should I make the test use a different value on WinDies? |
Actually, my windows env var syntax was wrong, it should be |
lerna exec
Thanks for all the help @evocateur! |
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Motivation and Context
The README example in the exec section would not supply any argument to npm view.
How Has This Been Tested?
When I invoked the command properly, I discovered that environment variables are not expanded at all, so I enabled the shell option in the call to
spawn
.Types of changes
Checklist: