@@ -2,75 +2,75 @@ var test = require('tape');
22var path = require ( 'path' ) ;
33
44var getAllNodeModulePathsUpwards = function ( start , moduleDirectory ) {
5- if ( ! moduleDirectory ) { moduleDirectory = 'node_modules' ; }
6- var currentPath = start ;
7- var expectedDirs = [ '/' + path . join ( currentPath , moduleDirectory ) ] ;
8- while ( currentPath && currentPath !== '/' ) {
9- currentPath = path . join ( currentPath , '../' ) ;
10- expectedDirs . push ( '/' + path . join ( currentPath , moduleDirectory ) ) ;
11- }
12- return expectedDirs ;
13- }
5+ if ( ! moduleDirectory ) { moduleDirectory = 'node_modules' ; }
6+ var currentPath = start ;
7+ var expectedDirs = [ '/' + path . join ( currentPath , moduleDirectory ) ] ;
8+ while ( currentPath && currentPath !== '/' ) {
9+ currentPath = path . join ( currentPath , '../' ) ;
10+ expectedDirs . push ( '/' + path . join ( currentPath , moduleDirectory ) ) ;
11+ }
12+ return expectedDirs ;
13+ } ;
1414
1515var nodeModulesPaths = require ( '../lib/node-modules-paths' ) ;
1616
1717test ( 'node-modules-paths' , function ( t ) {
18- t . test ( 'no options' , function ( t ) {
19- var start = path . join ( __dirname , 'resolver' ) ;
20- var dirs = nodeModulesPaths ( start ) ;
18+ t . test ( 'no options' , function ( t ) {
19+ var start = path . join ( __dirname , 'resolver' ) ;
20+ var dirs = nodeModulesPaths ( start ) ;
2121
22- var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
22+ var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
2323
24- t . deepEqual ( dirs , expectedDirs ) ;
24+ t . deepEqual ( dirs , expectedDirs ) ;
2525
26- t . end ( ) ;
27- } ) ;
26+ t . end ( ) ;
27+ } ) ;
2828
29- t . test ( 'empty options' , function ( t ) {
30- var start = path . join ( __dirname , 'resolver' ) ;
31- var dirs = nodeModulesPaths ( start , { } ) ;
29+ t . test ( 'empty options' , function ( t ) {
30+ var start = path . join ( __dirname , 'resolver' ) ;
31+ var dirs = nodeModulesPaths ( start , { } ) ;
3232
33- var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
33+ var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
3434
35- t . deepEqual ( dirs , expectedDirs ) ;
35+ t . deepEqual ( dirs , expectedDirs ) ;
3636
37- t . end ( ) ;
38- } ) ;
37+ t . end ( ) ;
38+ } ) ;
3939
40- t . test ( 'with paths option' , function ( t ) {
41- var start = path . join ( __dirname , 'resolver' ) ;
42- var paths = [ 'a' , 'b' ] ;
43- var dirs = nodeModulesPaths ( start , { paths : paths } ) ;
40+ t . test ( 'with paths option' , function ( t ) {
41+ var start = path . join ( __dirname , 'resolver' ) ;
42+ var paths = [ 'a' , 'b' ] ;
43+ var dirs = nodeModulesPaths ( start , { paths : paths } ) ;
4444
45- var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
45+ var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
4646
47- t . deepEqual ( dirs , expectedDirs . concat ( paths ) ) ;
47+ t . deepEqual ( dirs , expectedDirs . concat ( paths ) ) ;
4848
49- t . end ( ) ;
50- } ) ;
49+ t . end ( ) ;
50+ } ) ;
5151
52- t . test ( 'with moduleDirectory option' , function ( t ) {
53- var start = path . join ( __dirname , 'resolver' ) ;
54- var paths = [ 'a' , 'b' ] ;
55- var dirs = nodeModulesPaths ( start , { paths : paths } ) ;
52+ t . test ( 'with moduleDirectory option' , function ( t ) {
53+ var start = path . join ( __dirname , 'resolver' ) ;
54+ var paths = [ 'a' , 'b' ] ;
55+ var dirs = nodeModulesPaths ( start , { paths : paths } ) ;
5656
57- var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
57+ var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
5858
59- t . deepEqual ( dirs , expectedDirs . concat ( paths ) ) ;
59+ t . deepEqual ( dirs , expectedDirs . concat ( paths ) ) ;
6060
61- t . end ( ) ;
62- } ) ;
61+ t . end ( ) ;
62+ } ) ;
6363
64- t . test ( 'with moduleDirectory and paths options' , function ( t ) {
65- var start = path . join ( __dirname , 'resolver' ) ;
66- var paths = [ 'a' , 'b' ] ;
67- var moduleDirectory = 'not node modules' ;
68- var dirs = nodeModulesPaths ( start , { paths : paths , moduleDirectory : moduleDirectory } ) ;
64+ t . test ( 'with moduleDirectory and paths options' , function ( t ) {
65+ var start = path . join ( __dirname , 'resolver' ) ;
66+ var paths = [ 'a' , 'b' ] ;
67+ var moduleDirectory = 'not node modules' ;
68+ var dirs = nodeModulesPaths ( start , { paths : paths , moduleDirectory : moduleDirectory } ) ;
6969
70- var expectedDirs = getAllNodeModulePathsUpwards ( start , moduleDirectory ) ;
70+ var expectedDirs = getAllNodeModulePathsUpwards ( start , moduleDirectory ) ;
7171
72- t . deepEqual ( dirs , expectedDirs . concat ( paths ) ) ;
72+ t . deepEqual ( dirs , expectedDirs . concat ( paths ) ) ;
7373
74- t . end ( ) ;
75- } ) ;
74+ t . end ( ) ;
75+ } ) ;
7676} ) ;
0 commit comments