@@ -9,6 +9,7 @@ interface INpmOpts {
9
9
10
10
export class NodePackageManager implements INodePackageManager {
11
11
constructor ( private $childProcess : IChildProcess ,
12
+ private $logger : ILogger ,
12
13
private $options : IOptions ) { }
13
14
14
15
public getCache ( ) : string {
@@ -37,15 +38,46 @@ export class NodePackageManager implements INodePackageManager {
37
38
}
38
39
39
40
public install ( packageName : string , pathToSave : string , config ?: any ) : IFuture < any > {
40
- if ( this . $options . disableNpmInstall ) {
41
- return Future . fromResult ( ) ;
42
- }
43
- if ( this . $options . ignoreScripts ) {
44
- config = config || { } ;
45
- config [ "ignore-scripts" ] = true ;
46
- }
41
+ return ( ( ) => {
42
+ if ( this . $options . disableNpmInstall ) {
43
+ return ;
44
+ }
45
+ if ( this . $options . ignoreScripts ) {
46
+ config = config || { } ;
47
+ config [ "ignore-scripts" ] = true ;
48
+ }
47
49
48
- return this . loadAndExecute ( "install" , [ pathToSave , packageName ] , { config : config } ) ;
50
+ try {
51
+ return this . loadAndExecute ( "install" , [ pathToSave , packageName ] , { config : config } ) . wait ( ) ;
52
+ } catch ( err ) {
53
+ if ( err . code === "EPEERINVALID" ) {
54
+ // Not installed peer dependencies are treated by npm 2 as errors, but npm 3 treats them as warnings.
55
+ // We'll show them as warnings and let the user install them in case they are needed.
56
+ // The strucutre of the error object in such case is:
57
+ // { [Error: The package @angular /[email protected] does not satisfy its siblings' peerDependencies requirements!]
58
+ // code: 'EPEERINVALID',
59
+ // packageName: '@angular/core',
60
+ // packageVersion: '2.1.0-beta.0',
61
+ // peersDepending:
62
+ // { '@angular /[email protected] ': '2.1.0-beta.0',
63
+ // '@angular/[email protected] ': '2.1.0-beta.0',
64
+ // '@angular/[email protected] ': '2.1.0-beta.0',
65
+ // '@angular/[email protected] ': '2.1.0-beta.0',
66
+ // '@angular/[email protected] ': '2.1.0-beta.0',
67
+ // '@angular/[email protected] ': '2.1.0-beta.0',
68
+ // '@angular/[email protected] ': '2.1.0-beta.0',
69
+ // '@angular/[email protected] ': '2.1.0-beta.0',
70
+ // '@ngrx/[email protected] ': '^2.0.0',
71
+ // '@ngrx/[email protected] ': '^2.0.0',
72
+ // '[email protected] ': '~2.0.0' } }
73
+ this . $logger . warn ( err . message ) ;
74
+ this . $logger . trace ( "Required peerDependencies are: " , err . peersDepending ) ;
75
+ } else {
76
+ // All other errors should be handled by the caller code.
77
+ throw err ;
78
+ }
79
+ }
80
+ } ) . future < any > ( ) ( ) ;
49
81
}
50
82
51
83
public uninstall ( packageName : string , config ?: any , path ?: string ) : IFuture < any > {
0 commit comments