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

Use shell option when spawning lerna exec #761

Merged
merged 8 commits into from Apr 13, 2017

Conversation

jwb
Copy link
Contributor

@jwb jwb commented Apr 13, 2017

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

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@evocateur
Copy link
Member

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,
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link
Member

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");
      });
    });
  });

Copy link
Member

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.

Copy link
Contributor Author

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.

@jwb
Copy link
Contributor Author

jwb commented Apr 13, 2017

Added an integration test that fails on the master branch and passes with the fix.

Copy link
Member

@evocateur evocateur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jwb!

@evocateur
Copy link
Member

oh noes Windows :P

@jwb
Copy link
Contributor Author

jwb commented Apr 13, 2017

How should I make the test use a different value on WinDies?

@evocateur
Copy link
Member

Actually, my windows env var syntax was wrong, it should be %LERNA_PACKAGE_NAME% apparently

@evocateur evocateur changed the title Correct environment variable reference Use shell option when spawning lerna exec Apr 13, 2017
@evocateur evocateur merged commit bed393e into lerna:master Apr 13, 2017
@jwb
Copy link
Contributor Author

jwb commented Apr 13, 2017

Thanks for all the help @evocateur!

@jwb jwb deleted the docfix/exec_env branch April 13, 2017 23:26
@lock
Copy link

lock bot commented Dec 27, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants