@@ -161,21 +161,15 @@ export interface LaunchResult {
161161
162162export function launchOmniSharp ( details : LaunchDetails ) : Promise < LaunchResult > {
163163 return new Promise < LaunchResult > ( ( resolve , reject ) => {
164- try {
165- return launch ( details ) . then ( result => {
166- // async error - when target not not ENEOT
167- result . process . on ( 'error' , reject ) ;
168-
169- // success after a short freeing event loop
170- setTimeout ( function ( ) {
171- resolve ( result ) ;
172- } , 0 ) ;
173- } , err => {
174- reject ( err ) ;
175- } ) ;
176- } catch ( err ) {
177- reject ( err ) ;
178- }
164+ launch ( details ) . then ( result => {
165+ // async error - when target not not ENEOT
166+ result . process . on ( 'error' , reject ) ;
167+
168+ // success after a short freeing event loop
169+ setTimeout ( function ( ) {
170+ resolve ( result ) ;
171+ } , 0 ) ;
172+ } ) ;
179173 } ) ;
180174}
181175
@@ -189,34 +183,31 @@ function launch(details: LaunchDetails): Promise<LaunchResult> {
189183}
190184
191185function launchWindows ( details : LaunchDetails ) : Promise < LaunchResult > {
192- return new Promise < LaunchResult > ( resolve => {
193-
194- function escapeIfNeeded ( arg : string ) {
195- const hasSpaceWithoutQuotes = / ^ [ ^ " ] .* .* [ ^ " ] / ;
196- return hasSpaceWithoutQuotes . test ( arg )
197- ? `"${ arg } "`
198- : arg ;
199- }
186+ function escapeIfNeeded ( arg : string ) {
187+ const hasSpaceWithoutQuotes = / ^ [ ^ " ] .* .* [ ^ " ] / ;
188+ return hasSpaceWithoutQuotes . test ( arg )
189+ ? `"${ arg } "`
190+ : arg ;
191+ }
200192
201- let args = details . args . slice ( 0 ) ; // create copy of details.args
202- args . unshift ( details . serverPath ) ;
203- args = [ [
204- '/s' ,
205- '/c' ,
206- '"' + args . map ( escapeIfNeeded ) . join ( ' ' ) + '"'
207- ] . join ( ' ' ) ] ;
208-
209- let process = spawn ( 'cmd' , args , < any > {
210- windowsVerbatimArguments : true ,
211- detached : false ,
212- cwd : details . cwd
213- } ) ;
193+ let args = details . args . slice ( 0 ) ; // create copy of details.args
194+ args . unshift ( details . serverPath ) ;
195+ args = [ [
196+ '/s' ,
197+ '/c' ,
198+ '"' + args . map ( escapeIfNeeded ) . join ( ' ' ) + '"'
199+ ] . join ( ' ' ) ] ;
200+
201+ let process = spawn ( 'cmd' , args , < any > {
202+ windowsVerbatimArguments : true ,
203+ detached : false ,
204+ cwd : details . cwd
205+ } ) ;
214206
215- return resolve ( {
216- process,
217- command : details . serverPath ,
218- usingMono : false
219- } ) ;
207+ return Promise . resolve ( {
208+ process,
209+ command : details . serverPath ,
210+ usingMono : false
220211 } ) ;
221212}
222213
@@ -233,48 +224,44 @@ function launchNix(details: LaunchDetails): Promise<LaunchResult> {
233224}
234225
235226function launchNixCoreCLR ( details : LaunchDetails ) : Promise < LaunchResult > {
236- return new Promise < LaunchResult > ( resolve => {
237- let process = spawn ( details . serverPath , details . args , {
238- detached : false ,
239- cwd : details . cwd
240- } ) ;
227+ let process = spawn ( details . serverPath , details . args , {
228+ detached : false ,
229+ cwd : details . cwd
230+ } ) ;
241231
242- return resolve ( {
243- process,
244- command : details . serverPath ,
245- usingMono : false
246- } ) ;
232+ return Promise . resolve ( {
233+ process,
234+ command : details . serverPath ,
235+ usingMono : false
247236 } ) ;
248237}
249238
250239function launchNixMono ( details : LaunchDetails ) : Promise < LaunchResult > {
251- return new Promise < LaunchResult > ( ( resolve , reject ) => {
252- return canLaunchMono ( ) . then ( ( ) => {
253- let args = details . args . slice ( 0 ) ; // create copy of details.args
254- args . unshift ( details . serverPath ) ;
255-
256- let process = spawn ( 'mono' , args , {
257- detached : false ,
258- cwd : details . cwd
259- } ) ;
240+ return canLaunchMono ( ) . then ( ( ) => {
241+ let args = details . args . slice ( 0 ) ; // create copy of details.args
242+ args . unshift ( details . serverPath ) ;
260243
261- return resolve ( {
262- process,
263- command : details . serverPath ,
264- usingMono : true
265- } ) ;
244+ let process = spawn ( 'mono' , args , {
245+ detached : false ,
246+ cwd : details . cwd
266247 } ) ;
248+
249+ return {
250+ process,
251+ command : details . serverPath ,
252+ usingMono : true
253+ } ;
267254 } ) ;
268255}
269256
270257function canLaunchMono ( ) : Promise < void > {
271258 return new Promise < void > ( ( resolve , reject ) => {
272259 hasMono ( '>=4.0.1' ) . then ( success => {
273260 if ( success ) {
274- return resolve ( ) ;
261+ resolve ( ) ;
275262 }
276263 else {
277- return reject ( new Error ( 'Cannot start Omnisharp because Mono version >=4.0.1 is required.' ) ) ;
264+ reject ( new Error ( 'Cannot start Omnisharp because Mono version >=4.0.1 is required.' ) ) ;
278265 }
279266 } ) ;
280267 } ) ;
0 commit comments