File tree 4 files changed +36
-3
lines changed
4 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ thiserror = "2"
37
37
deno_error = { version = " 0.5.3" , features = [" url" ] }
38
38
boxed_error = " 0.2.3"
39
39
deno_semver = { version = " 0.7.1" , optional = true }
40
- deno_package_json = { version = " 0.4 .0" , optional = true }
40
+ deno_package_json = { version = " 0.5 .0" , optional = true }
41
41
deno_path_util = " 0.3.0"
42
42
sys_traits.workspace = true
43
43
Original file line number Diff line number Diff line change @@ -942,6 +942,16 @@ fn resolve_patch_config_folders<TSys: FsRead + FsMetadata + FsReadDir>(
942
942
let resolve_patch_dir_url =
943
943
|raw_patch : & str | -> Result < Url , WorkspaceDiscoverError > {
944
944
let patch = ensure_trailing_slash ( raw_patch) ;
945
+ // support someone specifying an absolute path
946
+ if !cfg ! ( windows) && patch. starts_with ( '/' )
947
+ || cfg ! ( windows) && patch. chars ( ) . any ( |c| c == '\\' )
948
+ {
949
+ if let Ok ( value) =
950
+ deno_path_util:: url_from_file_path ( & PathBuf :: from ( patch. as_ref ( ) ) )
951
+ {
952
+ return Ok ( value) ;
953
+ }
954
+ }
945
955
let patch_dir_url =
946
956
root_config_file_directory_url. join ( & patch) . map_err ( |err| {
947
957
WorkspaceDiscoverErrorKind :: ResolvePatch {
Original file line number Diff line number Diff line change @@ -2235,6 +2235,7 @@ pub mod test {
2235
2235
2236
2236
use deno_path_util:: normalize_path;
2237
2237
use deno_path_util:: url_from_directory_path;
2238
+ use deno_path_util:: url_from_file_path;
2238
2239
use pretty_assertions:: assert_eq;
2239
2240
use serde_json:: json;
2240
2241
use sys_traits:: impls:: InMemorySys ;
@@ -2809,6 +2810,28 @@ pub mod test {
2809
2810
) ;
2810
2811
}
2811
2812
2813
+ #[ test]
2814
+ fn test_patch_absolute_path ( ) {
2815
+ let root_path = root_dir ( ) . join ( "../dir" ) ;
2816
+ let workspace_dir = workspace_for_root_and_member_with_fs (
2817
+ json ! ( {
2818
+ "patch" : [ root_path. to_string_lossy( ) . to_string( ) ] ,
2819
+ } ) ,
2820
+ json ! ( { } ) ,
2821
+ |fs| {
2822
+ fs. fs_insert_json ( root_dir ( ) . join ( "../dir/deno.json" ) , json ! ( { } ) ) ;
2823
+ } ,
2824
+ ) ;
2825
+ assert_eq ! ( workspace_dir. workspace. diagnostics( ) , vec![ ] ) ;
2826
+ let patch_folders =
2827
+ workspace_dir. workspace . patch_folders ( ) . collect :: < Vec < _ > > ( ) ;
2828
+ assert_eq ! ( patch_folders. len( ) , 1 ) ;
2829
+ assert_eq ! (
2830
+ patch_folders[ 0 ] . deno_json. as_ref( ) . unwrap( ) . specifier,
2831
+ url_from_file_path( & root_dir( ) . join( "../dir/deno.json" ) ) . unwrap( )
2832
+ )
2833
+ }
2834
+
2812
2835
#[ test]
2813
2836
fn test_root_member_imports_and_scopes ( ) {
2814
2837
let workspace_dir = workspace_for_root_and_member (
You can’t perform that action at this time.
0 commit comments