kentcdodds / cross-env

🔀 Cross platform setting of environment scripts
https://www.npmjs.com/package/cross-env
MIT License
6.32k stars 243 forks source link

remove duplicate of PATH environment variable on Windows #218

Closed aberkovsky closed 3 years ago

aberkovsky commented 5 years ago

What: Issue #216

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

How: I add patchPathEnv.js

function patchPathEnv(env) {
  if (isWindows() && env.Path && env.PATH) {
    delete env.Path
  }
}

remove duplicate variable if both exists.

Checklist:

codecov[bot] commented 5 years ago

Codecov Report

Merging #218 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #218   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           4      5    +1     
  Lines          78     84    +6     
  Branches       18     19    +1     
=====================================
+ Hits           78     84    +6
Impacted Files Coverage Δ
src/patch-path.js 100% <100%> (ø)
src/index.js 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 67f21c3...b212e54. Read the comment docs.

kentcdodds commented 3 years ago

https://github.com/kentcdodds/cross-env/issues/257