File tree 4 files changed +36
-2
lines changed
4 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,13 @@ interface IPluginsService {
5
5
getAllInstalledPlugins ( ) : IFuture < IPluginData [ ] > ;
6
6
ensureAllDependenciesAreInstalled ( ) : IFuture < void > ;
7
7
afterPrepareAllPlugins ( ) : IFuture < void > ;
8
+ /**
9
+ * Installs all devDependencies of the project.
10
+ * In case all of them are already installed, no operation will be executed.
11
+ * In case any of them is missing, all of them will be installed.
12
+ * @return {IFuture<void> }
13
+ */
14
+ installDevDependencies ( ) : IFuture < void > ;
8
15
}
9
16
10
17
interface IPluginData extends INodeModuleData {
@@ -53,6 +60,7 @@ interface IPluginVariablesService {
53
60
* @return {IFuture<string> } returns the changed plugin configuration file content.
54
61
*/
55
62
getPluginVariablePropertyName ( pluginData : IPluginData ) : string ;
63
+
56
64
}
57
65
58
66
interface IPluginVariableData {
Original file line number Diff line number Diff line change @@ -154,11 +154,20 @@ export class PlatformService implements IPlatformService {
154
154
} ) . future < string [ ] > ( ) ( ) ;
155
155
}
156
156
157
- @helpers . hook ( 'prepare' )
158
157
public preparePlatform ( platform : string ) : IFuture < void > {
159
158
return ( ( ) => {
160
159
this . validatePlatform ( platform ) ;
161
160
161
+ //Install dev-dependencies here, so before-prepare hooks will be executed correctly.
162
+ this . $pluginsService . installDevDependencies ( ) . wait ( ) ;
163
+
164
+ this . preparePlatformCore ( platform ) . wait ( ) ;
165
+ } ) . future < void > ( ) ( ) ;
166
+ }
167
+
168
+ @helpers . hook ( 'prepare' )
169
+ private preparePlatformCore ( platform : string ) : IFuture < void > {
170
+ return ( ( ) => {
162
171
platform = platform . toLowerCase ( ) ;
163
172
this . ensurePlatformInstalled ( platform ) . wait ( ) ;
164
173
Original file line number Diff line number Diff line change @@ -185,6 +185,22 @@ export class PluginsService implements IPluginsService {
185
185
return this . executeForAllInstalledPlatforms ( action ) ;
186
186
}
187
187
188
+ public installDevDependencies ( ) : IFuture < void > {
189
+ return ( ( ) => {
190
+ let installedDependencies = this . $fs . exists ( this . nodeModulesPath ) . wait ( ) ? this . $fs . readDirectory ( this . nodeModulesPath ) . wait ( ) : [ ] ;
191
+ let packageJsonContent = this . $fs . readJson ( this . getPackageJsonFilePath ( ) ) . wait ( ) ;
192
+ let devDependencies = _ . keys ( packageJsonContent . devDependencies ) ;
193
+ if ( devDependencies . length && ( this . $options . force || _ . difference ( devDependencies , installedDependencies ) . length ) ) {
194
+ let command = `npm install ${ devDependencies . join ( " " ) } ` ;
195
+ if ( this . $options . ignoreScripts ) {
196
+ command += "--ignore-scripts" ;
197
+ }
198
+ this . $logger . trace ( `Command for installing devDependencies is: '${ command } '.` ) ;
199
+ this . $childProcess . exec ( command , { cwd : this . $projectData . projectDir } ) . wait ( ) ;
200
+ }
201
+ } ) . future < void > ( ) ( ) ;
202
+ }
203
+
188
204
private get nodeModulesPath ( ) : string {
189
205
return path . join ( this . $projectData . projectDir , "node_modules" ) ;
190
206
}
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ function createTestInjector() {
49
49
} ,
50
50
ensureAllDependenciesAreInstalled : ( ) => {
51
51
return Future . fromResult ( ) ;
52
- }
52
+ } ,
53
+ installDevDependencies : ( ) => Future . fromResult ( )
53
54
} ) ;
54
55
testInjector . register ( "projectFilesManager" , ProjectFilesManagerLib . ProjectFilesManager ) ;
55
56
testInjector . register ( "hooksService" , stubs . HooksServiceStub ) ;
You can’t perform that action at this time.
0 commit comments