@@ -33,6 +33,7 @@ temp.track();
33
33
34
34
let assert = require ( "chai" ) . assert ;
35
35
let nodeModulesFolderName = "node_modules" ;
36
+ let packageJsonName = "package.json" ;
36
37
37
38
function createTestInjector ( ) : IInjector {
38
39
let testInjector = new yok . Yok ( ) ;
@@ -110,10 +111,10 @@ function createProject(testInjector: IInjector, dependencies?: any): string {
110
111
return tempFolder ;
111
112
}
112
113
113
- function setupProject ( ) : IFuture < any > {
114
+ function setupProject ( dependencies ?: any ) : IFuture < any > {
114
115
return ( ( ) => {
115
116
let testInjector = createTestInjector ( ) ;
116
- let projectFolder = createProject ( testInjector ) ;
117
+ let projectFolder = createProject ( testInjector , dependencies ) ;
117
118
118
119
let fs = testInjector . resolve ( "fs" ) ;
119
120
@@ -278,7 +279,7 @@ describe("Npm support tests", () => {
278
279
279
280
describe ( "Flatten npm modules tests" , ( ) => {
280
281
it ( "Doesn't handle the dependencies of devDependencies" , ( ) => {
281
- let projectSetup = setupProject ( ) . wait ( ) ;
282
+ let projectSetup = setupProject ( { } ) . wait ( ) ;
282
283
let testInjector = projectSetup . testInjector ;
283
284
let projectFolder = projectSetup . projectFolder ;
284
285
let appDestinationFolderPath = projectSetup . appDestinationFolderPath ;
@@ -297,9 +298,6 @@ describe("Flatten npm modules tests", () => {
297
298
let fs = testInjector . resolve ( "fs" ) ;
298
299
let tnsModulesFolderPath = path . join ( appDestinationFolderPath , "app" , "tns_modules" ) ;
299
300
300
- let lodashFolderPath = path . join ( tnsModulesFolderPath , "lodash" ) ;
301
- assert . isTrue ( fs . exists ( lodashFolderPath ) . wait ( ) ) ;
302
-
303
301
let gulpFolderPath = path . join ( tnsModulesFolderPath , "gulp" ) ;
304
302
assert . isFalse ( fs . exists ( gulpFolderPath ) . wait ( ) ) ;
305
303
@@ -310,20 +308,20 @@ describe("Flatten npm modules tests", () => {
310
308
assert . isFalse ( fs . exists ( gulpJshint ) . wait ( ) ) ;
311
309
312
310
// Get all gulp dependencies
313
- let gulpDependencies = fs . readDirectory ( path . join ( projectFolder , nodeModulesFolderName , "gulp" , nodeModulesFolderName ) ) . wait ( ) ;
314
- _ . each ( gulpDependencies , dependency => {
311
+ let gulpJsonContent = fs . readJson ( path . join ( projectFolder , nodeModulesFolderName , "gulp" , packageJsonName ) ) . wait ( ) ;
312
+ _ . each ( _ . keys ( gulpJsonContent . dependencies ) , dependency => {
315
313
assert . isFalse ( fs . exists ( path . join ( tnsModulesFolderPath , dependency ) ) . wait ( ) ) ;
316
314
} ) ;
317
315
318
316
// Get all gulp-jscs dependencies
319
- let gulpJscsDependencies = fs . readDirectory ( path . join ( projectFolder , nodeModulesFolderName , "gulp-jscs" , nodeModulesFolderName ) ) . wait ( ) ;
320
- _ . each ( gulpJscsDependencies , dependency => {
317
+ let gulpJscsJsonContent = fs . readJson ( path . join ( projectFolder , nodeModulesFolderName , "gulp-jscs" , packageJsonName ) ) . wait ( ) ;
318
+ _ . each ( _ . keys ( gulpJscsJsonContent . dependencies ) , dependency => {
321
319
assert . isFalse ( fs . exists ( path . join ( tnsModulesFolderPath , dependency ) ) . wait ( ) ) ;
322
320
} ) ;
323
321
324
322
// Get all gulp-jshint dependencies
325
- let gulpJshintDependencies = fs . readDirectory ( path . join ( projectFolder , nodeModulesFolderName , "gulp-jshint" , nodeModulesFolderName ) ) . wait ( ) ;
326
- _ . each ( gulpJshintDependencies , dependency => {
323
+ let gulpJshintJsonContent = fs . readJson ( path . join ( projectFolder , nodeModulesFolderName , "gulp-jshint" , packageJsonName ) ) . wait ( ) ;
324
+ _ . each ( _ . keys ( gulpJshintJsonContent . dependencies ) , dependency => {
327
325
assert . isFalse ( fs . exists ( path . join ( tnsModulesFolderPath , dependency ) ) . wait ( ) ) ;
328
326
} ) ;
329
327
} ) ;
0 commit comments