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: remove dash from environment variables #195

Merged
merged 1 commit into from
Mar 16, 2021

Conversation

AriPerkkio
Copy link
Contributor

What:

Fixes #194.

Replaces dash characters (-) from SCRIPTS_ environment variables with _.
In practice SCRIPTS_PRE-COMMIT is now SCRIPTS_PRE_COMMIT.

Why:

Bash does not support environment variables with dash characters (-).
This cannot be reproduced with git-bash on windows but appears in Debian 10.

How:

When SCRIPTS_ environment variables are added replace all dashes with underscores.
Searched and checked all usage of parseEnv and process.env.

Checklist:

  • Documentation N/A
  • Tests
  • Ready to be merged

Manual test:
Without this fix I was unable to pass pre-commit hook of this repository. With the fix applied pre-commit hook runs successfully.

@codecov
Copy link

codecov bot commented Mar 16, 2021

Codecov Report

Merging #195 (a36821c) into main (3b4b884) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #195   +/-   ##
=======================================
  Coverage   63.15%   63.15%           
=======================================
  Files          21       21           
  Lines         589      589           
  Branches      221      221           
=======================================
  Hits          372      372           
  Misses        176      176           
  Partials       41       41           
Impacted Files Coverage Δ
src/run-script.js 97.72% <ø> (ø)
src/scripts/test.js 100.00% <100.00%> (ø)
src/scripts/validate.js 100.00% <100.00%> (ø)

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 3b4b884...a36821c. Read the comment docs.

@@ -47,7 +47,7 @@ function getEnv() {
return envCopy
},
{
[`SCRIPTS_${script.toUpperCase()}`]: true,
[`SCRIPTS_${script.toUpperCase().replace(/-/g, '_')}`]: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If previous SCRIPTS_ environment variables were considered as public API it wouldn't harm to also include them here - in addition to the new ones.

Copy link
Owner

Choose a reason for hiding this comment

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

It seems like it never really worked in the first place so I don't think they could have been considered public either way 🙃

Copy link
Owner

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Perfect! Thank you 👏

@@ -47,7 +47,7 @@ function getEnv() {
return envCopy
},
{
[`SCRIPTS_${script.toUpperCase()}`]: true,
[`SCRIPTS_${script.toUpperCase().replace(/-/g, '_')}`]: true,
Copy link
Owner

Choose a reason for hiding this comment

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

It seems like it never really worked in the first place so I don't think they could have been considered public either way 🙃

@kentcdodds kentcdodds merged commit 9539ba2 into kentcdodds:main Mar 16, 2021
@kentcdodds
Copy link
Owner

@all-contributors please add @AriPerkkio for code and tests

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @AriPerkkio! 🎉

@github-actions
Copy link

🎉 This PR is included in version 8.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@mpeyper
Copy link
Contributor

mpeyper commented Mar 17, 2021

I'm not sure why, but this patch update has caused our build to suddenly fail with lint errors. I'm happy to fix up the errors and warnings, but just a FYI about it. I'm not even entirely sure it's caused by this change, but it's the only thing referenced in the bump.

For reference.

@AriPerkkio
Copy link
Contributor Author

AriPerkkio commented Mar 17, 2021

I think that is actually a real issue in the code base. Previously your CI did not run [lint] due to bash losing the SCRIPTS_PRE-COMMIT environment variable. Here's a CI run where [lint] is missing. https://github.com/testing-library/react-hooks-testing-library/runs/2043088432?check_suite_focus=true

Now that CI runs the lint step it is actually finding real issues.

lint: preCommit ? null : ifScript('lint', 'npm run lint --silent'),

Edit: Oh right there is actually a lint step in the earlier run too. Missed that single line in verbose output. 🤦‍♂️

@mpeyper
Copy link
Contributor

mpeyper commented Mar 17, 2021

Yeah, I'm not sure why it's an issue now, the rules it's complaining about have been around for at least a few months. I think it's something along the lines what you're saying and however this was broken before, it's now doing the right thing so we should fix it (although my fix it to disable the rules because they're too stylistic for my taste).

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

Successfully merging this pull request may close these issues.

[pre-commit]: test step hangs due to --watch
3 participants