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

PATH variable replacement on Windows envirement #216

Closed
aberkovsky opened this issue Oct 14, 2019 · 3 comments
Closed

PATH variable replacement on Windows envirement #216

aberkovsky opened this issue Oct 14, 2019 · 3 comments

Comments

@aberkovsky
Copy link

  • cross-env version: 6.0.3
  • node version: 10.16.3
  • npm (or yarn) version: 6.11.3
  • OS version: windows 10

Relevant code or config

"test": "cross-env-shell PATH="../node_modules/.bin:$PATH" echo $PATH"

What you did:
Im try to add to PATH environment variable the parent .bin directory

What happened:
'echo' printed all paths, but wihtout my

Problem description:
Problem in the name of 'PATH' variable in Windows envirement, it has lower case 'Path'
Line below was fine
"test": "cross-env-shell Path="../node_modules/.bin:$Path" echo $Path"

Suggested solution:
Use the 'path-key' module for PATH variable replacement.

@kentcdodds
Copy link
Owner

Yes, this is an interesting problem. I think it's a worthwhile feature, so I'd be happy to accept a pull request for this. Would you be willing to implement that? I'm not sure we need to use path-key because the code will literally just be: const pathKey = isWindows ? 'Path' : 'PATH' (thanks to https://github.com/kentcdodds/cross-env/blob/master/src/is-windows.js).

Would you be interested in implementing this?

@aberkovsky
Copy link
Author

The problem was deeper...

On Windows operating systems, environment variables are case-insensitive.
However, if when you spawn a new process and pass the env with two variables (PATH and Path), in this new process process.env will contains both variables, and this breaks the subsequent logic.

Npm has logic to set both Path and PATH (if exist) variables on Windows, and by default used Path on Windows.
But if I use cgwin terminal on Windows for example, process.env contains PATH.

@kentcdodds
Copy link
Owner

#257

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

No branches or pull requests

2 participants