-
Notifications
You must be signed in to change notification settings - Fork 5.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
feat: deno vendor #13670
Merged
Merged
feat: deno vendor #13670
Changes from 36 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
fadf48a
Committing for backup purposes.
dsherret 8532d19
Add copyrights.
dsherret 9699a5c
Merge branch 'main' into deno_vendor
dsherret e0db996
Starting to add text changes.
dsherret 383a962
Somewhat working.
dsherret 85ab7ed
Slight fix.
dsherret 31c4996
Better import map and leave output files the same more
dsherret e5fd1f4
Merge remote-tracking branch 'upstream/main' into deno_vendor
dsherret 591042d
Small fixes. Need to resolve the todos... might be a bit of work.
dsherret 5e6022a
Lots of bugs, but slowly getting there. Will need deno_graph improvem…
dsherret 52c7818
- Inspect the source code itself to get the specifier text
dsherret 6a54b35
Basic testing infrastructure.
dsherret 677f492
Fix more issues. It seems to be working decently now.
dsherret 8317c87
Maintain casing of extensions when able
dsherret 855dbe4
Merge branch 'main' into deno_vendor
dsherret cf746ae
More tests.
dsherret a981b53
- derived import map and functionality test
dsherret bd77405
Merge remote-tracking branch 'upstream/main' into deno_vendor
dsherret 2974cd1
Support x-typescript-types headers
dsherret fe1413f
Fix and add tests for default export detection.
dsherret 36bc916
Add flags test.
dsherret 9762a40
More integration tests and fixes.
dsherret b77ddb5
Add sub command description
dsherret 8c16515
Add test for an existing import map.
dsherret 4286ffd
Tests for dynamic imports
dsherret 8d10e4d
Add support for more flags.
dsherret 72fb9b4
Updates based on self review.
dsherret c8a8aa5
Fix fs_util test
dsherret 3d097a5
Maybe fix mac.
dsherret f04366c
Fix mac issue on a mac
dsherret 4056996
Probably fix on all operating systems.......
dsherret d147900
Referencing a different origin should add entry to "imports"
dsherret 8b10b6a
Add message on success.
dsherret b3b98cc
Merge branch 'main' into deno_vendor
dsherret 326f399
Fix clippy issues on main.
dsherret dd8d561
Update for new deno_graph changes.
dsherret bfa2ee9
Add context to canonicalize.
dsherret 90bce37
Use first non-remote entry point in output message.
dsherret File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -362,6 +362,34 @@ pub fn path_has_trailing_slash(path: &Path) -> bool { | |
} | ||
} | ||
|
||
/// Gets a path with the specified file stem suffix. | ||
/// | ||
/// Ex. `file.ts` with suffix `_2` returns `file_2.ts` | ||
pub fn path_with_stem_suffix(path: &Path, suffix: &str) -> PathBuf { | ||
if let Some(file_name) = path.file_name().map(|f| f.to_string_lossy()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if let Some(file_stem) = path.file_stem().map(|f| f.to_string_lossy()) { | ||
if let Some(ext) = path.extension().map(|f| f.to_string_lossy()) { | ||
return if file_stem.to_lowercase().ends_with(".d") { | ||
path.with_file_name(format!( | ||
"{}{}.{}.{}", | ||
&file_stem[..file_stem.len() - ".d".len()], | ||
suffix, | ||
// maintain casing | ||
&file_stem[file_stem.len() - "d".len()..], | ||
ext | ||
)) | ||
} else { | ||
path.with_file_name(format!("{}{}.{}", file_stem, suffix, ext)) | ||
}; | ||
} | ||
} | ||
|
||
path.with_file_name(format!("{}{}", file_name, suffix)) | ||
} else { | ||
path.with_file_name(suffix) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
@@ -730,4 +758,44 @@ mod tests { | |
assert_eq!(result, expected); | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_path_with_stem_suffix() { | ||
assert_eq!( | ||
path_with_stem_suffix(&PathBuf::from("/"), "_2"), | ||
PathBuf::from("/_2") | ||
); | ||
assert_eq!( | ||
path_with_stem_suffix(&PathBuf::from("/test"), "_2"), | ||
PathBuf::from("/test_2") | ||
); | ||
assert_eq!( | ||
path_with_stem_suffix(&PathBuf::from("/test.txt"), "_2"), | ||
PathBuf::from("/test_2.txt") | ||
); | ||
assert_eq!( | ||
path_with_stem_suffix(&PathBuf::from("/test/subdir"), "_2"), | ||
PathBuf::from("/test/subdir_2") | ||
); | ||
assert_eq!( | ||
path_with_stem_suffix(&PathBuf::from("/test/subdir.other.txt"), "_2"), | ||
PathBuf::from("/test/subdir.other_2.txt") | ||
); | ||
assert_eq!( | ||
path_with_stem_suffix(&PathBuf::from("/test.d.ts"), "_2"), | ||
PathBuf::from("/test_2.d.ts") | ||
); | ||
assert_eq!( | ||
path_with_stem_suffix(&PathBuf::from("/test.D.TS"), "_2"), | ||
PathBuf::from("/test_2.D.TS") | ||
); | ||
assert_eq!( | ||
path_with_stem_suffix(&PathBuf::from("/test.d.mts"), "_2"), | ||
PathBuf::from("/test_2.d.mts") | ||
); | ||
assert_eq!( | ||
path_with_stem_suffix(&PathBuf::from("/test.d.cts"), "_2"), | ||
PathBuf::from("/test_2.d.cts") | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Trailing comma support.