@@ -10,7 +10,7 @@ let which = require('which'); // Mocked in tests
10
10
const grabModuleData = require ( './grab-module-data' ) ;
11
11
const grabProject = require ( './grab-project' ) ;
12
12
const lookup = require ( './lookup' ) ;
13
- const npm = require ( './npm ' ) ;
13
+ const packageManager = require ( './package-manager ' ) ;
14
14
const tempDirectory = require ( './temp-directory' ) ;
15
15
const unpack = require ( './unpack' ) ;
16
16
@@ -29,14 +29,28 @@ exports.windows = windows;
29
29
* 5. Output the results.
30
30
**/
31
31
32
- function find ( app , context , next ) {
33
- which ( app , function ( err , resolved ) {
32
+ function findNode ( context , next ) {
33
+ which ( 'node' , function ( err , resolved ) {
34
34
if ( err ) {
35
- next ( Error ( app + ' not found in path!' ) ) ;
35
+ next ( err ) ;
36
36
return ;
37
37
}
38
- context . emit ( 'data' , 'verbose' , context . module . name + ' using-' + app ,
39
- resolved ) ;
38
+ context . emit ( 'data' , 'verbose' , context . module . name + ' using-node' ,
39
+ resolved ) ;
40
+ next ( null , context ) ;
41
+ } ) ;
42
+ }
43
+
44
+ function findPackageManagers ( context , next ) {
45
+ packageManager . getPackageManagers ( ( err , res ) => {
46
+ if ( err ) {
47
+ next ( err ) ;
48
+ return ;
49
+ }
50
+
51
+ context . npmPath = res . npm ;
52
+ context . yarnPath = res . yarn ;
53
+
40
54
next ( null , context ) ;
41
55
} ) ;
42
56
}
@@ -46,13 +60,13 @@ function init(context, next) {
46
60
if ( ! windows ) {
47
61
if ( context . options . uid )
48
62
context . emit ( 'data' , 'verbose' , context . module . name + ' using-uid' ,
49
- context . options . uid ) ;
63
+ context . options . uid ) ;
50
64
if ( context . options . gid )
51
65
context . emit ( 'data' , 'verbose' , context . module . name + ' using-gid' ,
52
- context . options . gid ) ;
66
+ context . options . gid ) ;
53
67
}
54
68
context . emit ( 'data' , 'silly' , context . module . name + ' init-detail' ,
55
- context . module ) ;
69
+ context . module ) ;
56
70
next ( null , context ) ; // Inject the context
57
71
}
58
72
@@ -98,15 +112,15 @@ Tester.prototype.run = function() {
98
112
99
113
async . waterfall ( [
100
114
init . bind ( null , this ) ,
101
- find . bind ( null , 'node' ) ,
102
- find . bind ( null , 'npm' ) ,
115
+ findNode ,
116
+ findPackageManagers ,
103
117
tempDirectory . create ,
104
118
grabModuleData ,
105
119
lookup ,
106
120
grabProject ,
107
121
unpack ,
108
- npm . install ,
109
- npm . test
122
+ packageManager . install ,
123
+ packageManager . test
110
124
] , ( err ) => {
111
125
if ( ! this . cleanexit ) {
112
126
const payload = {
@@ -136,7 +150,7 @@ Tester.prototype.run = function() {
136
150
} ) ;
137
151
} ;
138
152
139
- Tester . prototype . cleanup = function ( ) {
153
+ Tester . prototype . cleanup = function ( ) {
140
154
this . cleanexit = true ;
141
155
const payload = {
142
156
name : this . module . name || this . module . raw ,
0 commit comments