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: Make app package.json load error tolerant #479

Merged
merged 3 commits into from Aug 12, 2018

Conversation

sudo-suhas
Copy link
Collaborator

@codecov
Copy link

codecov bot commented Aug 8, 2018

Codecov Report

Merging #479 into master will decrease coverage by 0.81%.
The diff coverage is 60%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #479      +/-   ##
==========================================
- Coverage   98.74%   97.93%   -0.82%     
==========================================
  Files          12       12              
  Lines         239      242       +3     
  Branches       28       28              
==========================================
+ Hits          236      237       +1     
- Misses          3        5       +2
Impacted Files Coverage Δ
src/findBin.js 91.3% <60%> (-8.7%) ⬇️
src/getConfig.js 100% <0%> (ø) ⬆️

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 c350a0e...1a7b8a2. Read the comment docs.

let pkg
try {
// eslint-disable-next-line import/no-dynamic-require, global-require
pkg = require(`${process.cwd()}/package.json`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is going to happen if I run commit from a sub-directory? The idea was that lint-staged can still go up enough levels to locate the package.json. AFAIK this won't work anymore from sub-dirs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We want to look at the package.json responsible for the pre-commit hook right? That is the same as process.cwd(). In any case, like I mentioned, it won't break any valid config as we tolerate errors, if any, faced while loading it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Replied with more info in #477 (comment)

Commit from sub-directory works fine.

@okonet
Copy link
Collaborator

okonet commented Aug 8, 2018

Sorry but I thought it's better to keep the discussion about this in the original PR since it brings more context. See #477 (comment)

okonet
okonet previously approved these changes Aug 9, 2018
@sudo-suhas
Copy link
Collaborator Author

@okonet I won't be able to merge this because it brings down the coverage just a tiny bit. Could you please squash and merge?

@okonet okonet merged commit d59fad7 into master Aug 12, 2018
@okonet okonet deleted the fix/tolerate-pkg-load-err branch August 12, 2018 16:29
@okonet
Copy link
Collaborator

okonet commented Aug 12, 2018

Done

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

Successfully merging this pull request may close these issues.

None yet

2 participants