-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
misc: refactor collect-strings.js to use glob and work on windows #9406
Conversation
`${path.sep}.git`, | ||
`${path.sep}scripts`, | ||
`${path.sep}node_modules`, | ||
`${path.sep}test${path.sep}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i kinda hate this, wb this instead
[
'/.git',
'/scripts',
'/node_modules',
'/test/',
'-test.js',
'-renderer.js',
].map(str => str.replace(/\//g, path.sep));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh, this seems even more obtuse imo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually like @connorjclark's suggestion, the readability of the paths is the important thing IMO, the fact that we want to support multiple OS is the secondary concern, maybe just add the
// Ensure we use the OS-specific path separator
comment to the map line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, works on windows, so that's nice.
`${path.sep}.git`, | ||
`${path.sep}scripts`, | ||
`${path.sep}node_modules`, | ||
`${path.sep}test${path.sep}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meh, this seems even more obtuse imo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % nit
`${path.sep}.git`, | ||
`${path.sep}scripts`, | ||
`${path.sep}node_modules`, | ||
`${path.sep}test${path.sep}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually like @connorjclark's suggestion, the readability of the paths is the important thing IMO, the fact that we want to support multiple OS is the secondary concern, maybe just add the
// Ensure we use the OS-specific path separator
comment to the map line?
sooooo...what if we just switched to using |
Co-Authored-By: Patrick Hulce <[email protected]>
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only "I consent." in this pull request. Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
+1. I was kinda surprised to see us doing recursive directory descent ourselves. i guess it'd be something a la glob.sync("**/*.js", {
ignore: ignoredPathComponents
}, fn); though we could also read in our .gitignore and give that to ignore. Would take care of most of these. |
|
running |
Updated. Will have to continue when I'm on a windows machine again. But:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this file's defense, it was written several months before glob was added to our deps and traversal isn't that hard :P
const files = glob.sync('**/*.js', { | ||
cwd: dir, | ||
// TODO: why doesn't this work ... | ||
// ignore: ignoredPathComponents, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably because our ignored patterns aren't globs yet :)
whoops, root is not what we want, never mind! :) |
I think you actually want something like
Maybe there's a better way, though. |
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
ready to gogogo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you have the approvals @connorjclark were you wanting a re-review? :)
cwd: LH_ROOT, | ||
ignore: ignoredPathComponents, | ||
}); | ||
for (const relativePathToRoot of files) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (const relativePathToRoot of files) { | |
for (const relativePathFromRoot of files) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or filePathRelativeToRoot? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relativeToRootPath
to match absolutePath
.
well it was 10PM and I just did a weird merge. wanted @exterkamp to stamp |
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@exterkamp probably should take a look since there is a bit changing in here and he just spent so much quality time with collect-strings :)
_processPlaceholderDirectIcu(icuDefn, examples); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace like this comes down to author preference and should really be discussed in the original PR rather than changed in the next commit (inviting style edit wars). Presumably @exterkamp preferred it and no one brought it up in the review, so unless there's a reason to change it, the default move should be to leave it unchanged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 leave the spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok sorry bud
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Didn't test on Windows on the latest iteration, but I did before and it was good, and I will again later today.
_processPlaceholderDirectIcu(icuDefn, examples); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 leave the spaces.
@@ -382,82 +379,77 @@ const seenStrings = new Map(); | |||
let collisions = 0; | |||
|
|||
/** | |||
* @param {string} dir | |||
* @param {Record<string, ICUMessageDefn>} strings | |||
* @param {string} dir absolute path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment on this, something like
* Collects all lhl messsages defined in UIString vars from within Javascript files located in dir,
* and converts them into ctc format.
* @param {string} dir | ||
* @param {Record<string, ICUMessageDefn>} strings | ||
* @param {string} dir absolute path | ||
* @return {Record<string, ICUMessageDefn>} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea with the returning, I like this better!
strings[seenId].meaning = strings[seenId].description; | ||
collisions++; | ||
} | ||
collisions++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to @paulirish for keeping this global so this isn't a problem 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry i have no idea what your comment is referencing but this line of code looks like i screwed up a merge?
is it supposed to double count collisions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm looks good
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
i tested it already btw. mergin' |
Fixes #9403.