@@ -9,6 +9,7 @@ import * as path from 'path';
99import * as fs from 'fs' ;
1010import * as os from 'os' ;
1111import * as semver from 'semver' ;
12+ import { execChildProcess } from './../common'
1213import { Logger } from './../logger'
1314
1415const MINIMUM_SUPPORTED_DOTNET_CLI : string = '1.0.0-preview2-003121' ;
@@ -79,13 +80,14 @@ export class CoreClrDebugUtil
7980 // This function checks for the presence of dotnet on the path and ensures the Version
8081 // is new enough for us.
8182 // Returns: a promise that returns a DotnetInfo class
82- // Throws: An CotNetCliError () from the return promise if either dotnet does not exist or is too old.
83+ // Throws: An DotNetCliError () from the return promise if either dotnet does not exist or is too old.
8384 public checkDotNetCli ( ) : Promise < DotnetInfo >
8485 {
8586 let dotnetInfo = new DotnetInfo ( ) ;
8687
87- return this . spawnChildProcess ( 'dotnet' , [ '--info' ] , process . cwd ( ) , ( data : Buffer ) => {
88- let lines : string [ ] = data . toString ( ) . replace ( / \r / mg, '' ) . split ( '\n' ) ;
88+ return execChildProcess ( 'dotnet --info' , process . cwd ( ) )
89+ . then ( ( data : string ) => {
90+ let lines : string [ ] = data . replace ( / \r / mg, '' ) . split ( '\n' ) ;
8991 lines . forEach ( line => {
9092 let match : RegExpMatchArray ;
9193 if ( match = / ^ \ V e r s i o n : \s * ( [ ^ \s ] .* ) $ / . exec ( line ) ) {
@@ -116,38 +118,6 @@ export class CoreClrDebugUtil
116118 } ) ;
117119 }
118120
119- public spawnChildProcess ( process : string , args : string [ ] , workingDirectory : string , onStdout ?: ( data : Buffer ) => void , onStderr ?: ( data : Buffer ) => void ) : Promise < void > {
120- const promise = new Promise < void > ( ( resolve , reject ) => {
121- const child = child_process . spawn ( process , args , { cwd : workingDirectory } ) ;
122-
123- if ( ! onStdout ) {
124- onStdout = ( data ) => { console . log ( `${ data } ` ) ; } ;
125- }
126- child . stdout . on ( 'data' , onStdout ) ;
127-
128- if ( ! onStderr ) {
129- onStderr = ( data ) => { console . error ( `${ data } ` ) ; } ;
130- }
131- child . stderr . on ( 'data' , onStderr ) ;
132-
133- child . on ( 'close' , ( code : number ) => {
134- if ( code != 0 ) {
135- console . log ( `${ process } exited with error code ${ code } ` ) ; ;
136- reject ( new Error ( code . toString ( ) ) ) ;
137- }
138- else {
139- resolve ( ) ;
140- }
141- } ) ;
142-
143- child . on ( 'error' , ( error : Error ) => {
144- reject ( error ) ;
145- } ) ;
146- } ) ;
147-
148- return promise ;
149- }
150-
151121 public static existsSync ( path : string ) : boolean {
152122 try {
153123 fs . accessSync ( path , fs . F_OK ) ;
0 commit comments