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 Path/PathBuf in deno dir #2559

Merged
merged 21 commits into from
Jun 24, 2019

Conversation

bartlomieju
Copy link
Member

This is preliminary work towards #2057

Refactoring //cli/deno_dir.rs to use more concrete types, because there is a hell lot of &str arguments

@bartlomieju
Copy link
Member Author

@ry PTAL if this direction is satisfactory. Handling of paths was replaced with use of PathBuf/Path. Now I'll tackle specifiers and referrers in deno_dir and change them to Url

@bartlomieju
Copy link
Member Author

@ry please review - I'd rather do specifier refactor to Url in followup PR - this one is pretty convoluted already. Additionally there's #2477 that you said you wanted to put in next release and that would cause a lot of conflicts during rebase.

@bartlomieju
Copy link
Member Author

CC @kitsonk

@bartlomieju bartlomieju changed the title WIP feat: use concrete types in deno dir refactor: use Path/PathBuf in deno dir Jun 23, 2019
@@ -27,6 +27,18 @@ use std::str;
use url;
use url::Url;

fn normalize_path(path: &Path) -> PathBuf {
Copy link
Member

Choose a reason for hiding this comment

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

Does this even make sense in when using Path and PathBuf instead of String?

I think you should try removing this function entirely.

Copy link
Member Author

@bartlomieju bartlomieju Jun 24, 2019

Choose a reason for hiding this comment

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

I believe it does... PTAL at this comment.

I tried removing this method, but that caused Windows build to start failing.

I'd prefer to normalize all paths to use forwards slashes everywhere in our codebase, just to simplify manipulating for us, std::fs methods are able to use forward slashes appropriately on Windows.

#[cfg(test)]
mod tests {
use super::*;
use tempfile::TempDir;

fn normalize_to_str(path: &Path) -> String {
normalize_path(path).to_str().unwrap().to_string()
}
Copy link
Member

Choose a reason for hiding this comment

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

Try removing this... does it still work?

@ry
Copy link
Member

ry commented Jun 24, 2019

@bartlomieju Please merge with master

@bartlomieju
Copy link
Member Author

@ry merged

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.

LGTM

@ry ry merged commit 70a9859 into denoland:master Jun 24, 2019
@bartlomieju bartlomieju deleted the feat-concrete_types_in_deno_dir branch June 24, 2019 17:43
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