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

Throw error with correct code when node exists #6

Closed
wants to merge 1 commit into from
Closed

Throw error with correct code when node exists #6

wants to merge 1 commit into from

Conversation

neezer
Copy link

@neezer neezer commented Dec 15, 2016

I've the following helper method to create directories:

const mkdirSync = fs => (dirPath) => {
  try {
    fs.mkdirSync(dirPath);
  } catch (e) {
    if (e.code !== 'EEXIST') {
      throw e;
    }
  }
};

Unfortunately, this doesn't work with memfs, as addDir/addFile will throw a non-system error if a node exists (with no code defined).

This PR throws an error closer to what Node itself would actually throw: https://nodejs.org/api/errors.html#errors_system_errors


Lemme know if you need me to change anything about this PR to get it merged in. Really enjoyed working with memfs, particularly for testing. Thanks for your hard work!

@neezer
Copy link
Author

neezer commented Dec 15, 2016

Aph, just realized your using TypeScript as your source... I'll re-open later once I update. Sorry!

@neezer neezer closed this Dec 15, 2016
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.

1 participant