@@ -27,7 +27,7 @@ import { LoadedCLI } from './dotnet.factory';
2727export class DotNetClient {
2828 constructor ( private cliCommand : LoadedCLI , public cwd ?: string ) { }
2929
30- new ( template : dotnetTemplate , parameters ?: dotnetNewOptions ) : Buffer {
30+ new ( template : dotnetTemplate , parameters ?: dotnetNewOptions ) : void {
3131 let cmd = `${ this . cliCommand . command } new ${ template } ` ;
3232 if ( parameters ) {
3333 parameters = swapArrayFieldValueUsingMap ( parameters , 'flag' , newKeyMap ) ;
@@ -37,7 +37,7 @@ export class DotNetClient {
3737 return this . logAndExecute ( cmd ) ;
3838 }
3939
40- build ( project : string , parameters ?: dotnetBuildOptions ) : Buffer {
40+ build ( project : string , parameters ?: dotnetBuildOptions ) : void {
4141 let cmd = `${ this . cliCommand . command } build ${ project } ` ;
4242 if ( parameters ) {
4343 parameters = swapArrayFieldValueUsingMap ( parameters , 'flag' , buildKeyMap ) ;
@@ -71,7 +71,7 @@ export class DotNetClient {
7171 project : string ,
7272 watch ?: boolean ,
7373 parameters ?: dotnetTestOptions ,
74- ) : Buffer | ChildProcess {
74+ ) : void | ChildProcess {
7575 let cmd = watch ? ` watch --project ${ project } test` : `test ${ project } ` ;
7676 cmd = `${ this . cliCommand . command } ${ cmd } ` ;
7777
@@ -103,7 +103,7 @@ export class DotNetClient {
103103 project : string ,
104104 pkg : string ,
105105 parameters ?: dotnetAddPackageOptions ,
106- ) : Buffer {
106+ ) : void {
107107 let cmd = `${ this . cliCommand . command } add ${ project } package ${ pkg } ` ;
108108 if ( parameters ) {
109109 parameters = swapArrayFieldValueUsingMap (
@@ -117,7 +117,7 @@ export class DotNetClient {
117117 return this . logAndExecute ( cmd ) ;
118118 }
119119
120- addProjectReference ( hostCsProj : string , targetCsProj : string ) : Buffer {
120+ addProjectReference ( hostCsProj : string , targetCsProj : string ) : void {
121121 return this . logAndExecute (
122122 `${ this . cliCommand . command } add ${ hostCsProj } reference ${ targetCsProj } ` ,
123123 ) ;
@@ -128,7 +128,7 @@ export class DotNetClient {
128128 parameters ?: dotnetPublishOptions ,
129129 publishProfile ?: string ,
130130 extraParameters ?: string ,
131- ) : Buffer {
131+ ) : void {
132132 let cmd = `${ this . cliCommand . command } publish ${ project } ` ;
133133 if ( parameters ) {
134134 parameters = swapArrayFieldValueUsingMap (
@@ -148,22 +148,22 @@ export class DotNetClient {
148148 return this . logAndExecute ( cmd ) ;
149149 }
150150
151- installTool ( tool : string ) : Buffer {
151+ installTool ( tool : string ) : void {
152152 const cmd = `${ this . cliCommand . command } tool install ${ tool } ` ;
153153 return this . logAndExecute ( cmd ) ;
154154 }
155155
156- restorePackages ( project : string ) : Buffer {
156+ restorePackages ( project : string ) : void {
157157 const cmd = `${ this . cliCommand . command } restore ${ project } ` ;
158158 return this . logAndExecute ( cmd ) ;
159159 }
160160
161- restoreTools ( ) : Buffer {
161+ restoreTools ( ) : void {
162162 const cmd = `${ this . cliCommand . command } tool restore` ;
163163 return this . logAndExecute ( cmd ) ;
164164 }
165165
166- format ( project : string , parameters ?: dotnetFormatOptions ) : Buffer {
166+ format ( project : string , parameters ?: dotnetFormatOptions ) : void {
167167 let cmd = `${ this . cliCommand . command } format ${ project } ` ;
168168 if ( parameters ) {
169169 parameters = swapArrayFieldValueUsingMap (
@@ -177,12 +177,21 @@ export class DotNetClient {
177177 return this . logAndExecute ( cmd ) ;
178178 }
179179
180- printSdkVersion ( ) : Buffer {
181- return this . logAndExecute ( 'dotnet --version' ) ;
180+ getSdkVersion ( ) : Buffer {
181+ const cmd = 'dotnet --version' ;
182+ return this . execute ( cmd ) ;
182183 }
183184
184- private logAndExecute ( cmd : string ) : Buffer {
185+ printSdkVersion ( ) : void {
186+ this . logAndExecute ( 'dotnet --version' ) ;
187+ }
188+
189+ private logAndExecute ( cmd : string ) : void {
185190 console . log ( `Executing Command: ${ cmd } ` ) ;
186- return execSync ( cmd , { stdio : 'inherit' , cwd : this . cwd || process . cwd ( ) } ) ;
191+ execSync ( cmd , { stdio : 'inherit' , cwd : this . cwd || process . cwd ( ) } ) ;
192+ }
193+
194+ private execute ( cmd : string ) : Buffer {
195+ return execSync ( cmd , { cwd : this . cwd || process . cwd ( ) } ) ;
187196 }
188197}
0 commit comments