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

fix: handle undefined process.env #54

Merged
merged 2 commits into from
Jun 26, 2022
Merged

fix: handle undefined process.env #54

merged 2 commits into from
Jun 26, 2022

Conversation

farnabaz
Copy link
Contributor

Kleur highly uses in multiple packages like micromark and it may include in client bundle, therefore there are some cases that process.env could be undefined.

This change ensure that missing process.env does not lead to runtime exception

@lukeed
Copy link
Owner

lukeed commented Mar 14, 2022

Where / what environments does this occur? If process is defined (the line before), then process.env will also be there.

@farnabaz
Copy link
Contributor Author

If process is defined (the line before), then process.env will also be there.

It is true in node environment, but as for client bundlers this is not valid all the time.
Some may have use cases for process but they don't provide process.env.

For example Nuxt bundler provide some info under process variable. But process.env is not defined in bundle and using kleur cause undefined error.

@Saul-Mirone
Copy link

Saul-Mirone commented May 26, 2022

+1, some frameworks in browser environment will remove other properties in process.

@kevinmarrec
Copy link

+1, process.env could not be available in browser, and this PR just ensure it doesn't break if it is not.

@codecov-commenter
Copy link

Codecov Report

Merging #54 (e455184) into master (598f24c) will decrease coverage by 1.22%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #54      +/-   ##
==========================================
- Coverage   98.77%   97.54%   -1.23%     
==========================================
  Files           2        2              
  Lines         163      163              
  Branches       28       30       +2     
==========================================
- Hits          161      159       -2     
- Misses          1        3       +2     
  Partials        1        1              
Impacted Files Coverage Δ
colors.mjs 96.22% <100.00%> (-1.89%) ⬇️
index.mjs 98.18% <100.00%> (-0.91%) ⬇️

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 598f24c...e455184. Read the comment docs.

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

Successfully merging this pull request may close these issues.

5 participants