@@ -10,7 +10,7 @@ import {sleep} from "../../../lib/common/helpers";
10
10
let glob = require ( "glob" ) ;
11
11
12
12
export class NodeModulesBuilder implements INodeModulesBuilder {
13
- constructor (
13
+ constructor ( private $childProcess : IChildProcess ,
14
14
private $fs : IFileSystem ,
15
15
private $projectData : IProjectData ,
16
16
private $projectDataService : IProjectDataService ,
@@ -133,6 +133,13 @@ export class NodeModulesBuilder implements INodeModulesBuilder {
133
133
// Force copying if the destination doesn't exist.
134
134
lastModifiedTime = null ;
135
135
}
136
+
137
+ //TODO: plamen5kov: WIP
138
+ let depJsonStr = this . $childProcess . exec ( "npm list --prod --json" ) . wait ( ) ;
139
+ let prodDependenciesJson = JSON . parse ( depJsonStr ) ;
140
+ let productionDepArray = this . getProductionDependencyNames ( prodDependenciesJson ) ;
141
+
142
+
136
143
let nodeModules = this . getChangedNodeModules ( absoluteOutputPath , platform , lastModifiedTime ) . wait ( ) ;
137
144
138
145
const resolver = new NpmDependencyResolver ( this . $projectData . projectDir ) ;
@@ -152,6 +159,29 @@ export class NodeModulesBuilder implements INodeModulesBuilder {
152
159
} ) . future < void > ( ) ( ) ;
153
160
}
154
161
162
+ private getProductionDependencyNames ( inputJson : any ) : any {
163
+ var finalDependencies :any = { } ;
164
+ var queue :any = [ ] ;
165
+
166
+ inputJson . level = 0 ;
167
+ queue . push ( inputJson )
168
+
169
+ while ( queue . length > 0 ) {
170
+ var parent = queue . pop ( ) ;
171
+
172
+ if ( parent . dependencies ) {
173
+ for ( var dep in parent . dependencies ) {
174
+ var currentDependency = parent . dependencies [ dep ] ;
175
+ currentDependency . level = parent . level + 1 ;
176
+ queue . push ( currentDependency ) ;
177
+ finalDependencies [ dep ] = currentDependency ;
178
+ }
179
+ }
180
+ }
181
+
182
+ return finalDependencies ;
183
+ }
184
+
155
185
public cleanNodeModules ( absoluteOutputPath : string , platform : string ) : void {
156
186
shelljs . rm ( "-rf" , absoluteOutputPath ) ;
157
187
}
0 commit comments