File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 1+ const parseDependencyName = ( dependency : string ) => {
2+ const match = dependency . match ( / ( .* ?) \/ / ) ;
3+
4+ if ( match ) return match [ 1 ] ;
5+ return dependency ;
6+ } ;
7+
18export default class DependencyNotFoundError extends Error {
29 constructor ( dependencyName : string ) {
310 super ( ) ;
411 this . payload = {
5- dependency : dependencyName ,
12+ dependency : parseDependencyName ( dependencyName ) ,
613 } ;
714 }
815 type = 'dependency-not-found' ;
Original file line number Diff line number Diff line change 1+ import DependencyError from './dependency-not-found-error' ;
2+
3+ test ( 'it handles normal deps correctly' , ( ) => {
4+ const error = new DependencyError ( 'redux-form' ) ;
5+
6+ expect ( error . payload ) . toEqual ( { dependency : 'redux-form' } ) ;
7+ } ) ;
8+
9+ test ( 'it parses dependency names with slashes correctly' , ( ) => {
10+ const error = new DependencyError ( 'redux-form/immutable' ) ;
11+
12+ expect ( error . payload ) . toEqual ( { dependency : 'redux-form' } ) ;
13+ } ) ;
14+
15+ test ( 'it parses dependency names with multiple slashes correctly' , ( ) => {
16+ const error = new DependencyError ( 'redux-form/immutable/koekjes' ) ;
17+
18+ expect ( error . payload ) . toEqual ( { dependency : 'redux-form' } ) ;
19+ } ) ;
You can’t perform that action at this time.
0 commit comments