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 on the main export and be silent when using resolveFrom.silent() #4

Merged
merged 7 commits into from
Apr 28, 2017

Conversation

ranyitz
Copy link
Contributor

@ranyitz ranyitz commented Apr 27, 2017

As a response to this PR- #3
and - sindresorhus/import-from#1

index.js Outdated
return null;
if (silent) {
try {
_resolveFileName(fromDir, fromFile, moduleId);
Copy link
Owner

@sindresorhus sindresorhus Apr 27, 2017

Choose a reason for hiding this comment

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

This needs to return. Probably needs a test to confirm this is working.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Funny, the tests were covering it and it worked, there was another return statement at the end of the function, for the "non silent" case.
because it didn't fall to the cache it just worked :)

test.js Outdated
t.is(m.silent('fixture', './nonexistent'), null);
const resolveFromfixture = m.bind(null, 'fixture');
t.regex(resolveFromfixture('./fixture'), /fixture\/fixture\.js$/);
const silentResolveFromfixture = m.silent.bind(null, 'fixture');
Copy link
Owner

Choose a reason for hiding this comment

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

The silent assertions should be in a separate test.

index.js Outdated
@@ -2,7 +2,15 @@
const path = require('path');
const Module = require('module');

module.exports = (fromDir, moduleId) => {
const _resolveFileName = (fromDir, fromFile, moduleId) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering why you prefixed this with underscores? Might have missed something in the conversation though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I removed the underscores.

@sindresorhus sindresorhus changed the title Throw on the main export and silent when using resolveFrom.silent() + ES2015ify Throw on the main export and be silent when using resolveFrom.silent() Apr 28, 2017
@sindresorhus sindresorhus merged commit 2277c65 into sindresorhus:master Apr 28, 2017
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.

3 participants