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

Make resolver filename aware #18

Merged
merged 1 commit into from
Nov 10, 2015

Conversation

aredridel
Copy link
Contributor

This allows a resolver to take the filename of the currently processed file into account.

@totherik
Copy link
Contributor

It looks like line 42 also needs to be updated to accept the filename parameter. Even though it's resolved as a module, IIRC JSON would still fulfill that condition.

@aredridel
Copy link
Contributor Author

Right you are.

@aredridel
Copy link
Contributor Author

Updated.

@totherik
Copy link
Contributor

Great, thanks. Any thoughts on why the test didn't cover/catch that scenario? Can you update the tests for that code path if it's not covered?

Also, I like this direction, but (as we discussed in person) I'd like to explore fully committing to metadata such that we can make the API change once and hopefully not have to update it again. For example, could the second argument be an object instead of string? (Open to other suggestions as well.)

function handler(value, metadata, cb) {
    // metadata -> { filename: 'my/file.json' }
}

@aredridel
Copy link
Contributor Author

Test just didn't extend to that case -- the coverage was the same minimal that another test used. Both could be improved.

@aredridel
Copy link
Contributor Author

I wonder if there's another object to pass instead of arbitrary metadata -- a stream or some input that is actually the thing we're asking about.

@@ -193,8 +198,10 @@ exports.create = function create(parent) {
return handler;
});

tasks.unshift(function init(done) {
tasks.unshift(tasks[0].length == 2 ? function init(done) {
done(null, data);
Copy link
Member

Choose a reason for hiding this comment

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

can you elaborate on reason for checking the length ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Backward compatibility: If the function takes 1 parameter (above), call with value, expect a return value (since there's no callback); if it takes two, pass just the value, last parameter is the callback; if it takes more (new interface!), pass it the value, the filename being processed, and the callback.

Copy link
Member

Choose a reason for hiding this comment

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

gotcha

@pvenkatakrishnan
Copy link
Member

👍

@aredridel
Copy link
Contributor Author

Don't merge yet -- still pending some design updates!

@totherik
Copy link
Contributor

totherik commented Feb 3, 2015

Where does this PR stand? Still pending?

@aredridel
Copy link
Contributor Author

This PR is done. I'd be happy having this merged.

pvenkatakrishnan pushed a commit that referenced this pull request Nov 10, 2015
@pvenkatakrishnan pvenkatakrishnan merged commit 129f38d into krakenjs:master Nov 10, 2015
@pvenkatakrishnan
Copy link
Member

will publish a patch.

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