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

Multi extension support #37

Merged
merged 4 commits into from
Jan 3, 2019
Merged

Multi extension support #37

merged 4 commits into from
Jan 3, 2019

Conversation

phated
Copy link
Member

@phated phated commented Dec 28, 2018

@sttk I've had this as a WIP for quite awhile but didn't submit it because the tests were very out-of-date and I wanted to get things passing before I sent it.

Can you review and determine if this is a proper solution for #26 and #34? I think I've properly accounted for all the weirdness around multiple extensions but another set of eyes is needed.

alansouzati and others added 2 commits December 28, 2018 14:13
Fixed supportsExtension check.

Fixed extensions for multi period.

Fixing typo on the extension.

Added tests for folders with dots.
@phated
Copy link
Member Author

phated commented Dec 28, 2018

I'd also like to get this landed before I rebase the project to inline with the other gulp repos.

Copy link
Contributor

@sttk sttk left a comment

Choose a reason for hiding this comment

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

I've finished reviewing. Please modify or reply for my few comments.

});
}

if(Object.keys(require.extensions).indexOf(usedExtension) !== -1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Boolean(require.extensions[ext]) is faster.
Or is it possible that a value of an existing key is falsy?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, it is possible that usedExtension is undefined and require.extensions[usedExtension] becomes require.extensions['undefined'].

Cancel the above comment, or move this line after checking config is not nullish if you will modify.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's fine to keep like this.

lib/extension.js Outdated
@@ -1,11 +1,19 @@
const path = require('path');

const EXTRE = /^[.]?[^.]+([.].*)$/;
const EXTRE = /\.[^.]+/g;
const LONGEXTRE = /^[.]?[^.]+([.].+)$/;
Copy link
Contributor

Choose a reason for hiding this comment

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

/^[.]?[^.]+([.].+)$/.exec('aaa.js.') returns [ 'aaa.js.', '.js.', ...].
And '.js.'.match(EXTRE) returns '.js'.
Is it correct that const LONGEXTRE = /^[.]?[^.]+([.][^.]+)$/;?

Copy link
Member Author

Choose a reason for hiding this comment

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

@sttk yeah, I think your regexp is better than mine. Let me come up with some tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

@sttk actually, it seems the LONGEXTRE needs to capture from the first . to the end of line, including future .s.

Copy link
Member Author

Choose a reason for hiding this comment

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

@sttk I can see what you are trying to achieve. What about using this RegExp: /^[.]?[^.]+([.].+[^.])$/ (visualized at regexper)

Copy link
Member Author

Choose a reason for hiding this comment

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

I've made the above changes that I suggested and added a test. Let me know what you think.

Copy link
Member Author

Choose a reason for hiding this comment

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

@sttk your above RegExp is pretty good but it completely rejects ANY path that has double dots. I think that is incorrect.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think some of these should return proper extensions, even though there's weird double-dot syntax inside the basename.

Sure. We should change EXTRE to support double-dot.

Copy link
Contributor

Choose a reason for hiding this comment

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

@phated Which should we adopt for EXTRE?

  1. '.bbb.ccc..js'.match(/\.+[^.]+/g); // => [ '.bbb', '.ccc', '..js' ]
  2. '.bbb.ccc..js'.match(/\.[^.]*/g); // => [ '.bbb', '.ccc', '.', '.js' ]

Copy link
Member Author

Choose a reason for hiding this comment

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

@sttk I think 2 is correct.

Copy link
Member Author

Choose a reason for hiding this comment

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

@sttk I just pushed changes that use your suggestion (2) and included tests. Let me know if you think that solves the issue.

@phated
Copy link
Member Author

phated commented Jan 3, 2019

@sttk I'm hoping you have a chance to review the small updates soon, I'd like to get this wrapped up before Monday.

Copy link
Contributor

@sttk sttk left a comment

Choose a reason for hiding this comment

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

I think this is good.

@phated phated merged commit 34f5e55 into master Jan 3, 2019
@phated
Copy link
Member Author

phated commented Jan 3, 2019

Thanks for reviewing @sttk!!!

@sttk
Copy link
Contributor

sttk commented Jan 3, 2019

@phated Great work!

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