1717// specific language governing permissions and limitations
1818// under the License.
1919
20+ import { spawn } from 'child_process'
21+ import { Command } from 'commander'
22+ import crypto from 'crypto'
2023import fs from 'fs'
2124import merge from 'lodash/fp/merge'
2225import os from 'os'
2326import path from 'path'
24- import crypto from 'crypto '
27+ import resolveBin from 'resolve-bin '
2528import util from 'util'
26- import { Command } from 'commander'
2729import Capabilities from './capabilities'
2830import Config from './config'
2931import ParseProxy from './proxy'
3032import { Configuration , SideRunnerAPI } from './types'
31- import { spawn } from 'child_process'
32-
33- const isWindows = os . platform ( ) === 'win32'
3433
3534const metadata = require ( '../package.json' )
3635
@@ -180,14 +179,7 @@ configuration.debugStartup &&
180179 console . debug ( 'Configuration:' , util . inspect ( configuration ) )
181180
182181// All the stuff that goes into a big wrapped jest command
183- const jestExecutable = isWindows ? 'jest.cmd' : 'jest'
184- const jestCommand = path . join (
185- __dirname ,
186- '..' ,
187- 'node_modules' ,
188- '.bin' ,
189- jestExecutable
190- )
182+ const jest = resolveBin . sync ( 'jest' )
191183const jestArgs = [
192184 '--config=' + path . join ( __dirname , '..' , 'jest.config.js' ) ,
193185 '--maxConcurrency=' + configuration . maxWorkers ,
@@ -209,8 +201,8 @@ const jestEnv = {
209201}
210202
211203configuration . debugStartup &&
212- console . debug ( 'Jest command:' , jestCommand , jestArgs , jestEnv )
213- spawn ( jestCommand , jestArgs , {
204+ console . debug ( 'Jest command:' , jest , jestArgs , jestEnv )
205+ spawn ( jest , jestArgs , {
214206 env : jestEnv ,
215207 shell : true ,
216208 stdio : 'inherit' ,
0 commit comments