Repository navigation
Adding image-size check script and pre-commit hook to run it - #758
Conversation
|
If I merge this, the images that already break this rule will prevent further merges until the image size issues are rectified, correct? |
| const path = require('path'); | ||
| const fs = require('fs'); | ||
|
|
||
| let fileArray = []; |
There was a problem hiding this comment.
Instead of storing it to an external array, I think we can return the result directly by filtering instead of mapping at the end of read.
.filter(file => typeof file === 'string')
.filter(image => fs.lstatSync(image).size > 1000000)
Can also be combined into one filter, if you would like.
Then we can just set const fileArray = read('src/images/').
|
|
||
| read('src/images/'); | ||
|
|
||
| if (fileArray.length > 0) { |
There was a problem hiding this comment.
This can be just if (fileArray.length) {} since 0 is the only case we care about.
|
|
||
| let fileArray = []; | ||
|
|
||
| const read = dir => |
There was a problem hiding this comment.
I know this is something small, but could this be renamed to readDir? read feels vague to me.
kevinkiklee
left a comment
There was a problem hiding this comment.
I didn't know about pre-commit. That's really cool. I learned something new.
|
Targets neutralized |
kylemh
left a comment
There was a problem hiding this comment.
Agreed with @kevinkiklee 's review. Also worried about using typeof in conjunction with const
0723bcd to
112fb6c
Compare
|
Gun #2 ready for re-check. |
Description of changes
Adds a pre-commit hook that recursively checks all images within the src/images folder. If they are above the 1MB size limit, this hook will console log the offending files and fail the commit.
Note:
In order to get this to PR, I ran my commit with a --no-verify flag because we have two offending files.
src/images/serviceSeals/USMCReserve.pngandsrc/images/Family-2.png. I will open a new issue to resize these images.Issue Resolved
Fixes #676