@@ -2,75 +2,75 @@ var test = require('tape');
2
2
var path = require ( 'path' ) ;
3
3
4
4
var 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
+ } ;
14
14
15
15
var nodeModulesPaths = require ( '../lib/node-modules-paths' ) ;
16
16
17
17
test ( '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 ) ;
21
21
22
- var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
22
+ var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
23
23
24
- t . deepEqual ( dirs , expectedDirs ) ;
24
+ t . deepEqual ( dirs , expectedDirs ) ;
25
25
26
- t . end ( ) ;
27
- } ) ;
26
+ t . end ( ) ;
27
+ } ) ;
28
28
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 , { } ) ;
32
32
33
- var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
33
+ var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
34
34
35
- t . deepEqual ( dirs , expectedDirs ) ;
35
+ t . deepEqual ( dirs , expectedDirs ) ;
36
36
37
- t . end ( ) ;
38
- } ) ;
37
+ t . end ( ) ;
38
+ } ) ;
39
39
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 } ) ;
44
44
45
- var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
45
+ var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
46
46
47
- t . deepEqual ( dirs , expectedDirs . concat ( paths ) ) ;
47
+ t . deepEqual ( dirs , expectedDirs . concat ( paths ) ) ;
48
48
49
- t . end ( ) ;
50
- } ) ;
49
+ t . end ( ) ;
50
+ } ) ;
51
51
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 } ) ;
56
56
57
- var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
57
+ var expectedDirs = getAllNodeModulePathsUpwards ( start ) ;
58
58
59
- t . deepEqual ( dirs , expectedDirs . concat ( paths ) ) ;
59
+ t . deepEqual ( dirs , expectedDirs . concat ( paths ) ) ;
60
60
61
- t . end ( ) ;
62
- } ) ;
61
+ t . end ( ) ;
62
+ } ) ;
63
63
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 } ) ;
69
69
70
- var expectedDirs = getAllNodeModulePathsUpwards ( start , moduleDirectory ) ;
70
+ var expectedDirs = getAllNodeModulePathsUpwards ( start , moduleDirectory ) ;
71
71
72
- t . deepEqual ( dirs , expectedDirs . concat ( paths ) ) ;
72
+ t . deepEqual ( dirs , expectedDirs . concat ( paths ) ) ;
73
73
74
- t . end ( ) ;
75
- } ) ;
74
+ t . end ( ) ;
75
+ } ) ;
76
76
} ) ;
0 commit comments