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

Fix getDestFilePath behavior for directories #52

Conversation

elucid
Copy link
Contributor

@elucid elucid commented Apr 5, 2016

getDestFilePath should always return null for directories.

@stefanpenner
Copy link
Collaborator

Thanks for the tests, I will unlikely be able to actually look into this for the next few days. (Traveling for conference, giving talks and such).

maybe @rwjblue has some spare cycles, if not I will try to dig in (and answer your question) as soon as I can, but it might be a few days.

@elucid
Copy link
Contributor Author

elucid commented May 12, 2016

Ping @stefanpenner

@elucid elucid force-pushed the dirs-with-extensions-should-not-be-matched branch 2 times, most recently from 4e85d48 to 39dccae Compare August 30, 2016 15:27
elucid added 2 commits August 30, 2016 12:15
In practice, most directories do not have extensions and as such return null when passed to getDestFilePath in a filter with extensions provided. This is important because canProcessFile by default uses this to determine whether a node should be processed. However, in the case where a directory happens to have a matched extension (e.g. the tree contains loader.js/loader.js and we are doing some processing on js files), we only want the loader.js file, and not the loader.js directory, to be processed.
@elucid elucid force-pushed the dirs-with-extensions-should-not-be-matched branch from 39dccae to e73fb44 Compare August 30, 2016 19:15
@elucid
Copy link
Contributor Author

elucid commented Aug 30, 2016

Hey @stefanpenner, it's been a while, and we still want to make this change :)

We've made an attempt at fixing our own failing tests by explicitly testing whether paths are directories to prevent the problem with extensions that broke the excluded from with fingerprint extensions.

We've tested this PR by locally npm linking it into both PRs ember-cli/broccoli-asset-rewrite#34 and ember-cli/broccoli-asset-rev#93, and then npm-linking the above broccoli-asset-rev PR into our product app. This takes rebuilds from ~10s to ~600ms.

We've also tested with a new ember app, npm linking in the same way.

Anyway, eager to get your thoughts on this.

/cc @ghedamat

@elucid elucid changed the title Add failing tests that specify getDestFilePath behavior for directories Fix getDestFilePath behavior for directories Aug 30, 2016
@@ -210,7 +210,26 @@ Filter.prototype.canProcessFile =
return !!this.getDestFilePath(relativePath);
};

Filter.prototype.isDirectory = function(relativePath) {
if (this.inputPaths === undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

when is this true?

var srcDir = this.inputPaths[0];
var path = srcDir + '/' + relativePath;

return fs.lstatSync(path).isDirectory();
Copy link
Collaborator

Choose a reason for hiding this comment

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

rather then stating again, lets pass entry from https://github.com/stefanpenner/broccoli-persistent-filter/blob/master/index.js#L125 to getDestFilePath, that way we can simply ask it entry.isDirectory() etc.

Filter.prototype.getDestFilePath = function(relativePath) {
// NOTE: relativePath may have been moved or unlinked
try {
Copy link
Collaborator

Choose a reason for hiding this comment

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

with the above suggestion, i suspect this is no longer required.

@stefanpenner
Copy link
Collaborator

@elucid sorry for letting this sit. Its hard to keep track of all this OSS stuff. I have left some comments, and will gladly help to make sure this lands promptly.

@stefanpenner
Copy link
Collaborator

addressed feedback and merged here: #109

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.

2 participants