Skip to content

fix: Make app package.json load error tolerant#479

Merged
okonet merged 3 commits into
masterfrom
fix/tolerate-pkg-load-err
Aug 12, 2018
Merged

fix: Make app package.json load error tolerant#479
okonet merged 3 commits into
masterfrom
fix/tolerate-pkg-load-err

Conversation

@sudo-suhas

Copy link
Copy Markdown
Contributor

@sudo-suhas sudo-suhas force-pushed the fix/tolerate-pkg-load-err branch from efb16d7 to 5305cb1 Compare August 8, 2018 03:55
@codecov

codecov Bot commented Aug 8, 2018

Copy link
Copy Markdown

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.

Comment thread src/findBin.js
let pkg
try {
// eslint-disable-next-line import/no-dynamic-require, global-require
pkg = require(`${process.cwd()}/package.json`)

Copy link
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
Contributor 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

okonet commented Aug 8, 2018

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Contributor 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

okonet commented Aug 12, 2018

Copy link
Copy Markdown
Collaborator

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.

2 participants