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: fs.readdir(__dirname) asset emission #267

Merged
merged 5 commits into from
Feb 10, 2022
Merged

fix: fs.readdir(__dirname) asset emission #267

merged 5 commits into from
Feb 10, 2022

Conversation

styfle
Copy link
Member

@styfle styfle commented Feb 9, 2022

I updated the code to special case fs.readdir() or fs.readdirSync() since these were being blocked here

nft/src/analyze.ts

Lines 829 to 831 in f5b7fcf

// do not emit __dirname
if (assetPath === dir + wildcardSuffix)
return false;

We can't modify that line however since its used by normal fs.readFile() and fs.readFileSync() which should not accidentally emit the entire directory.

I also updated an existing test since it was incorrectly looking for a single file from fs.readdir() when it should have been checking for all files.

@styfle styfle requested a review from ijjk as a code owner February 9, 2022 21:25
@styfle styfle mentioned this pull request Feb 9, 2022
@styfle styfle marked this pull request as draft February 9, 2022 21:47
@codecov
Copy link

codecov bot commented Feb 10, 2022

Codecov Report

Merging #267 (d74f698) into main (6a3d6cf) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #267      +/-   ##
==========================================
+ Coverage   80.58%   80.62%   +0.03%     
==========================================
  Files          13       13              
  Lines        1458     1461       +3     
  Branches      542      543       +1     
==========================================
+ Hits         1175     1178       +3     
  Misses        116      116              
  Partials      167      167              
Impacted Files Coverage Δ
src/analyze.ts 86.58% <100.00%> (+0.09%) ⬆️

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 6a3d6cf...d74f698. Read the comment docs.

@styfle styfle marked this pull request as ready for review February 10, 2022 00:34
@styfle styfle requested a review from guybedford February 10, 2022 00:34
@styfle styfle changed the title Fix dirname emit Fix fs.readdir(__dirname) asset emission Feb 10, 2022
@styfle styfle changed the title Fix fs.readdir(__dirname) asset emission fix: fs.readdir(__dirname) asset emission Feb 10, 2022
@styfle styfle merged commit 6b9b095 into main Feb 10, 2022
@styfle styfle deleted the fix-dirname-emit branch February 10, 2022 15:12
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.

2 participants