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

files on fs #158

Open
awinogradov opened this issue Aug 21, 2016 · 5 comments
Open

files on fs #158

awinogradov opened this issue Aug 21, 2016 · 5 comments

Comments

@awinogradov
Copy link

The code below create exception and node_modules wich use fs for config parsing fails if somebody wants to use them with mock-fs:

'use strict'

const mock = require('mock-fs')
const fs = require('fs')
const path = require('path')

mock({[process.cwd()]: mock.directory()});

fs.readFileSync(path.join(__dirname, 'package.json'))
@derhuerst
Copy link

As I realdy said in svg/svgo#574:

[afaik] You first have to tell mock-fs which files should be available in the mocked fs.

See the example in the docs.

@awinogradov
Copy link
Author

If I understand right I need to say false for creating process.cwd dir? After that, all node_modules connected with fs will work, right?

@derhuerst
Copy link

If I understand right I need to say false for creating process.cwd dir? After that, all node_modules connected with fs will work, right?

I don't understand. What do you mean by that?

@awinogradov
Copy link
Author

I mean I should set option for mock-fs wich will not create folder for process.cwd

@derhuerst
Copy link

Why would it create a directory? As I said: You need to specify which should be inside the directory. By default, a mock.directory() seems to be empty.

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

2 participants