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

refactor: Use PathBuf for paths in flag parsing and whitelists #3955

Merged
merged 5 commits into from
Feb 11, 2020

Conversation

nayeemrmn
Copy link
Collaborator

Follows from #3714.

@nayeemrmn nayeemrmn requested a review from ry February 10, 2020 18:33
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

Patch seems reasonable except for the glob part where I comment below...

What is the goal of this patch? does this fix something?

@bartlomieju PTAL

check: bool,
) -> Result<(), ErrBox> {
// TODO: improve glob to look for tsx?/jsx? files only
let glob_paths = maybe_files.unwrap_or_else(|| vec!["**/*".to_string()]);
let glob_paths = maybe_files.unwrap_or_else(|| vec![PathBuf::from("**/*")]);
Copy link
Member

Choose a reason for hiding this comment

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

This seems odd/wrong PathBuf::from("**/*") ...

Copy link
Member

@bartlomieju bartlomieju Feb 10, 2020

Choose a reason for hiding this comment

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

I agree with @ry - it'd be better to rename field on Subcommand::Format to globs and keep Vec<String> type.

Otherwise +1 from me, stricter types are always good

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As far as I've seen it's normal for glob patterns to be stored as "paths". They have distinctly separated segments (since any special syntax is limited to a segment), absoluteness, parent paths, it's useful to join() them, normalize() them, etc. Are you sure this is a problem?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, makes sense, I've seen glob/globset crate do that. LGTM

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @nayeemrmn

@bartlomieju bartlomieju merged commit 701ce9b into denoland:master Feb 11, 2020
bartlomieju added a commit to bartlomieju/deno that referenced this pull request Feb 11, 2020
@nayeemrmn nayeemrmn deleted the path-handling branch February 11, 2020 13:02
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