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

#172 - Support alternative fs implementations. #173

Closed
wants to merge 4 commits into from

Conversation

dazinator
Copy link

Allow an alternative fs implementation to be used, overriding the default based on graceful-fs

@jsf-clabot
Copy link

jsf-clabot commented Mar 19, 2019

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Mar 19, 2019

Codecov Report

Merging #173 into master will increase coverage by 0.01%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #173      +/-   ##
==========================================
+ Coverage   92.98%   92.99%   +0.01%     
==========================================
  Files          32       32              
  Lines        1140     1142       +2     
  Branches      262      263       +1     
==========================================
+ Hits         1060     1062       +2     
  Misses         80       80
Impacted Files Coverage Δ
lib/NodeJsInputFileSystem.js 36.84% <75%> (+7.43%) ⬆️

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 5c1495a...109aab6. Read the comment docs.

@webpack-bot
Copy link

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

@alexander-akait
Copy link
Member

Need add tests

@dazinator
Copy link
Author

I'm typically a dotnet developer, node environment is failry new to me. I can run tests via mocha etc. In terms of adding a new test, any guidance as to where I should add it? Do I create a new file for this issue under the tests directoy? Or should I append a new test to an existing file somewhere? Thanks

@alexander-akait
Copy link
Member

Create new file (example of test https://github.com/webpack/enhanced-resolve/blob/master/test/CachedInputFileSystem.js), test existing method with and without own fs

@dazinator
Copy link
Author

I am seeing a lot of test failures on windows, i'll log under a seperate issue.

@alexander-akait
Copy link
Member

@dazinator yep, we need fix their in separate issue, anyway feel free to send a PR with fixes too, a lot of developers work under linux so tests can be broken in some cases

@dazinator
Copy link
Author

Have added some tests.

@dazinator
Copy link
Author

I think this should meet the quality bar now but let me know if you need me to do anything further!

beforeEach(function() {});
afterEach(function() {
//fs.purge();
});
Copy link
Member

Choose a reason for hiding this comment

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

Need remove this

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

All good, one note

@webpack-bot
Copy link

@dazinator Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@evilebottnawi Please review the new changes.

@dazinator
Copy link
Author

@evilebottnawi Have made change requested.

Copy link
Member

@sokra sokra left a comment

Choose a reason for hiding this comment

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

I don't see why this change is needed. You can just write your own InputFileSystem class for your alternative filesystem. There is no major logic in NodeJsInputFileSystem.

@dazinator
Copy link
Author

dazinator commented Apr 9, 2019

@sokra I did consider that. I guess it comes down to a choice.

If this class is changed to allow the 'fs' it works with to be injected, then it saves having to create essentially a duplicate.

I thought that creating a custom input file system could then be reserved for when:

  1. you need to use something other than an 'fs' api to grab your files. Let's say you need to make a http call rec.
  2. You actually have some custom logic to decide on the file

I guess my thinking is that I wanted to save a consumer from having to create a custom input file system when neither of the above were true..

Essentially widening the responsibility of the class from:

"This class is responsible for working with node's fs for file access'

to:

'This class is responsible for working with an fs for file access"

@dazinator
Copy link
Author

Any further action required from me here or is this awaiting a decision

@sokra
Copy link
Member

sokra commented May 28, 2019

Essentially widening the responsibility of the class from:

"This class is responsible for working with node's fs for file access'

to:

'This class is responsible for working with an fs for file access"

The name is NodeJsFileSystem. It doesn't have a lot of logic. I don't think it makes sense to change this. sorry, but thanks for the PR anyway.

@sokra sokra closed this May 28, 2019
@dazinator
Copy link
Author

Ok thanks for considering. I'll create a duplicate class.

@dazinator
Copy link
Author

dazinator commented Jun 28, 2019

@sokra
I am adding feedback here because I recently stumbled across this PR again and it made me remember my frustration which I initially didn't voice. Do with this feedback what you will:
My only complaint is that having discussed this #172 and been told to submit a PR..
And then above being told to add tests..
Only then to be told the whole concept doesnt make sense to accept in the first place - sorry.
I know you must be busy but I wish you'd chimed in earlier. Time is an important resource for us all! That said I appreciate calls must be made, I just wish they were made a bit earlier in this particular case

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

Successfully merging this pull request may close these issues.

5 participants