File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -192,11 +192,22 @@ impl<Fs: FileSystem> Cache<Fs> {
192
192
cwd : Option < & Path > ,
193
193
) -> Result < & pnp:: Manifest , ResolveError > {
194
194
self . yarn_pnp_manifest . get_or_try_init ( || {
195
- // TODO: map to proper error
196
- let cwd =
197
- cwd. map_or_else ( || Cow :: Owned ( std:: env:: current_dir ( ) . unwrap ( ) ) , Cow :: Borrowed ) ;
198
- // TODO: map to proper error
199
- let manifest = pnp:: find_pnp_manifest ( & cwd) . unwrap ( ) . unwrap ( ) ;
195
+ let cwd = match cwd {
196
+ Some ( path) => Cow :: Borrowed ( path) ,
197
+ None => match std:: env:: current_dir ( ) {
198
+ Ok ( path) => Cow :: Owned ( path) ,
199
+ Err ( err) => return Err ( ResolveError :: from ( err) ) ,
200
+ } ,
201
+ } ;
202
+ let manifest = match pnp:: find_pnp_manifest ( & cwd) {
203
+ Ok ( manifest) => match manifest {
204
+ Some ( manifest) => manifest,
205
+ None => {
206
+ return Err ( ResolveError :: FailedToFindYarnPnpManifest ( cwd. to_path_buf ( ) ) ) ;
207
+ }
208
+ } ,
209
+ Err ( err) => return Err ( ResolveError :: YarnPnpError ( err) ) ,
210
+ } ;
200
211
Ok ( manifest)
201
212
} )
202
213
}
Original file line number Diff line number Diff line change @@ -112,6 +112,14 @@ pub enum ResolveError {
112
112
/// Occurs when alias paths reference each other.
113
113
#[ error( "Recursion in resolving" ) ]
114
114
Recursion ,
115
+
116
+ #[ cfg( feature = "yarn_pnp" ) ]
117
+ #[ error( "Failed to find yarn pnp manifest in {0}." ) ]
118
+ FailedToFindYarnPnpManifest ( PathBuf ) ,
119
+
120
+ #[ cfg( feature = "yarn_pnp" ) ]
121
+ #[ error( "{0}" ) ]
122
+ YarnPnpError ( pnp:: Error ) ,
115
123
}
116
124
117
125
impl ResolveError {
You can’t perform that action at this time.
0 commit comments