Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.

Windows cross-env example does not work as expected #153

Closed
achingbrain opened this issue Nov 7, 2017 · 5 comments · Fixed by m1guelpf/miguelpiedrafita.com#15, mono-js/mono-doc#9 or Yproximite/better-vue-input-tag#34

Comments

@achingbrain
Copy link
Contributor

The README has the following example:

{
  "scripts": {
    "parentScript": "cross-env GREET=\"Joe\" npm run childScript",
    "childScript": "echo Hello $GREET"
  }
}

If I run this on Windows using cmd.exe I get the following:

C:\path\to\project>npm run parentScript

> project@1.0.0 parentScript C:\path\to\project
> cross-env GREET="Joe" npm run childScript


> project@1.0.0 childScript C:\path\to\project
> echo Hello $GREET

Hello $GREET

That is, it does not interpolate the value of the env var GREET. If I change the $GREET line to %GREET% in childScript, I get the following:

C:\path\to\project>npm run parentScript

> project@1.0.0 parentScript C:\path\to\project
> cross-env GREET="Joe" npm run childScript


> project@1.0.0 childScript C:\path\to\project
> echo Hello %GREET%

Hello Joe

Each npm script is run in a subshell (cmd.exe by default on Windows) so I think that's why $GREET doesn't work, but the README seems to imply that it should, unless I've got the wrong end of the stick.

  • cross-env version: 5.1.1
  • node version: 6.11.3
  • npm version: 3.10.10
@kentcdodds
Copy link
Owner

I believe you're correct. Thanks for the catch! Could you make a pull request to improve the docs? Thanks!

@achingbrain
Copy link
Contributor Author

Sure, I can submit a PR that removes that section.

I'd like to understand why it was there in the first place though - was the expectation that it would work or was it an unimplemented feature or just a bug?

@kentcdodds
Copy link
Owner

I think it's a bug. I don't have a windows machine to test things on 😅

@achingbrain
Copy link
Contributor Author

Me neither, I just fire up VirtualBox with a Windows VM from time to time.

@kentcdodds
Copy link
Owner

Yeah, I've got a Windows VM for testing my web app, but I've not taken the time to set it up with git/node/etc.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants