@@ -83,6 +83,7 @@ function createProject(testInjector: IInjector, dependencies?: any): string {
83
83
}
84
84
} ;
85
85
packageJsonData [ "dependencies" ] = dependencies ;
86
+ packageJsonData [ "devDependencies" ] = { } ;
86
87
87
88
testInjector . resolve ( "fs" ) . writeJson ( path . join ( tempFolder , "package.json" ) , packageJsonData ) . wait ( ) ;
88
89
return tempFolder ;
@@ -131,14 +132,19 @@ function setupProject(): IFuture<any> {
131
132
} ) . future < any > ( ) ( ) ;
132
133
}
133
134
134
- function addDependencies ( testInjector : IInjector , projectFolder : string , dependencies : any ) : IFuture < void > {
135
+ function addDependencies ( testInjector : IInjector , projectFolder : string , dependencies : any , devDependencies ?: any ) : IFuture < void > {
135
136
return ( ( ) => {
136
137
let fs = testInjector . resolve ( "fs" ) ;
137
138
let packageJsonPath = path . join ( projectFolder , "package.json" ) ;
138
139
let packageJsonData = fs . readJson ( packageJsonPath ) . wait ( ) ;
139
140
140
141
let currentDependencies = packageJsonData . dependencies ;
141
142
_ . extend ( currentDependencies , dependencies ) ;
143
+
144
+ if ( devDependencies ) {
145
+ let currentDevDependencies = packageJsonData . devDependencies ;
146
+ _ . extend ( currentDevDependencies , devDependencies ) ;
147
+ }
142
148
fs . writeJson ( packageJsonPath , packageJsonData ) . wait ( ) ;
143
149
} ) . future < void > ( ) ( ) ;
144
150
}
@@ -176,4 +182,57 @@ describe("Npm support tests", () => {
176
182
assert . isTrue ( fs . exists ( bplistCreatorFolderPath ) . wait ( ) ) ;
177
183
assert . isTrue ( fs . exists ( bplistParserFolderPath ) . wait ( ) ) ;
178
184
} ) ;
185
+ } ) ;
186
+
187
+ describe ( "Flatten npm modules tests" , ( ) => {
188
+ it ( "Doesn't handle the dependencies of devDependencies" , ( ) => {
189
+ let projectSetup = setupProject ( ) . wait ( ) ;
190
+ let testInjector = projectSetup . testInjector ;
191
+ let projectFolder = projectSetup . projectFolder ;
192
+ let appDestinationFolderPath = projectSetup . appDestinationFolderPath ;
193
+
194
+ let devDependencies = {
195
+ "gulp" : "3.9.0" ,
196
+ "gulp-jscs" : "1.6.0" ,
197
+ "gulp-jshint" : "1.11.0"
198
+ } ;
199
+
200
+ addDependencies ( testInjector , projectFolder , { } , devDependencies ) . wait ( ) ;
201
+
202
+ preparePlatform ( testInjector ) . wait ( ) ;
203
+
204
+ // Assert
205
+ let fs = testInjector . resolve ( "fs" ) ;
206
+ let tnsModulesFolderPath = path . join ( appDestinationFolderPath , "app" , "tns_modules" ) ;
207
+
208
+ let lodashFolderPath = path . join ( tnsModulesFolderPath , "lodash" ) ;
209
+ assert . isTrue ( fs . exists ( lodashFolderPath ) . wait ( ) ) ;
210
+
211
+ let gulpFolderPath = path . join ( tnsModulesFolderPath , "gulp" ) ;
212
+ assert . isFalse ( fs . exists ( gulpFolderPath ) . wait ( ) ) ;
213
+
214
+ let gulpJscsFolderPath = path . join ( tnsModulesFolderPath , "gulp-jscs" ) ;
215
+ assert . isFalse ( fs . exists ( gulpJscsFolderPath ) . wait ( ) ) ;
216
+
217
+ let gulpJshint = path . join ( tnsModulesFolderPath , "gulp-jshint" ) ;
218
+ assert . isFalse ( fs . exists ( gulpJshint ) . wait ( ) ) ;
219
+
220
+ // Get all gulp dependencies
221
+ let gulpDependencies = fs . readDirectory ( path . join ( projectFolder , "node_modules" , "gulp" , "node_modules" ) ) . wait ( ) ;
222
+ _ . each ( gulpDependencies , dependency => {
223
+ assert . isFalse ( fs . exists ( path . join ( tnsModulesFolderPath , dependency ) ) . wait ( ) ) ;
224
+ } ) ;
225
+
226
+ // Get all gulp-jscs dependencies
227
+ let gulpJscsDependencies = fs . readDirectory ( path . join ( projectFolder , "node_modules" , "gulp-jscs" , "node_modules" ) ) . wait ( ) ;
228
+ _ . each ( gulpJscsDependencies , dependency => {
229
+ assert . isFalse ( fs . exists ( path . join ( tnsModulesFolderPath , dependency ) ) . wait ( ) ) ;
230
+ } ) ;
231
+
232
+ // Get all gulp-jshint dependencies
233
+ let gulpJshintDependencies = fs . readDirectory ( path . join ( projectFolder , "node_modules" , "gulp-jshint" , "node_modules" ) ) . wait ( ) ;
234
+ _ . each ( gulpJshintDependencies , dependency => {
235
+ assert . isFalse ( fs . exists ( path . join ( tnsModulesFolderPath , dependency ) ) . wait ( ) ) ;
236
+ } ) ;
237
+ } ) ;
179
238
} ) ;
0 commit comments