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

Add unpatch method #4

Closed
vjpr opened this issue Oct 29, 2017 · 8 comments
Closed

Add unpatch method #4

vjpr opened this issue Oct 29, 2017 · 8 comments

Comments

@vjpr
Copy link

vjpr commented Oct 29, 2017

I want to use this in tests. It would be great to have a unpatch method for after tests have run.

patchFs could return a method to unpatch.

Or maybe patchfs(require('fs')) will work?

@vjpr vjpr changed the title unpatch Add unpatch method Oct 29, 2017
@footearth
Copy link

The same requirement..
How to patchFs back to system fs
or unpatch?

@streamich
Copy link
Owner

What do you guys think about the following syntax:

import {patchFs} from 'fs-monkey';
import {vol} from 'memfs';

const unpatch = patchFs(vol);

// Do your stuff...

unpatch();

@streamich
Copy link
Owner

@footearth
Copy link

Thank you for the greate work first.
Pls check that the function 'unpatch' will print some debug msg use 'console.log'.

@footearth
Copy link

Now I use "postInstall" to fix it.
"postinstall": "sed -i '/console\\.log(bkp);/d' ./node_modules/fs-monkey/lib/patchFs.js"

@streamich
Copy link
Owner

@footearth Thanks for the find, my bad.

Fixed version coming soon.

@streamich
Copy link
Owner

https://github.com/streamich/fs-monkey/releases/tag/v0.3.1

@ndelangen
Copy link

This needs documentation

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

No branches or pull requests

4 participants