33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6+ import * as path from 'path' ;
7+
68import { URI , UriComponents } from 'vs/base/common/uri' ;
79import * as nls from 'vs/nls' ;
810import * as Objects from 'vs/base/common/objects' ;
911import { asThenable } from 'vs/base/common/async' ;
1012import { Event , Emitter } from 'vs/base/common/event' ;
13+ import { win32 } from 'vs/base/node/processes' ;
1114
1215import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions' ;
1316import * as tasks from 'vs/workbench/parts/tasks/common/tasks' ;
@@ -883,9 +886,12 @@ export class ExtHostTask implements ExtHostTaskShape {
883886 } ) ;
884887 }
885888
886- public $resolveVariables ( uriComponents : UriComponents , variables : string [ ] ) : any {
889+ public $resolveVariables ( uriComponents : UriComponents , toResolve : { process ?: { name : string ; cwd ?: string ; path ?: string } , variables : string [ ] } ) : Thenable < { process ?: string , variables : { [ key : string ] : string ; } } > {
887890 let uri : URI = URI . revive ( uriComponents ) ;
888- let result : { [ key : string ] : string ; } = Object . create ( null ) ;
891+ let result = {
892+ process : undefined as string ,
893+ variables : Object . create ( null )
894+ } ;
889895 let workspaceFolder = this . _workspaceService . resolveWorkspaceFolder ( uri ) ;
890896 let resolver = new ExtHostVariableResolverService ( this . _workspaceService , this . _editorService , this . _configurationService ) ;
891897 let ws : IWorkspaceFolder = {
@@ -896,10 +902,24 @@ export class ExtHostTask implements ExtHostTaskShape {
896902 throw new Error ( 'Not implemented' ) ;
897903 }
898904 } ;
899- for ( let variable of variables ) {
900- result [ variable ] = resolver . resolve ( ws , variable ) ;
905+ for ( let variable of toResolve . variables ) {
906+ result . variables [ variable ] = resolver . resolve ( ws , variable ) ;
907+ }
908+ if ( toResolve . process !== void 0 ) {
909+ let paths : string [ ] | undefined = undefined ;
910+ if ( toResolve . process . path !== void 0 ) {
911+ paths = toResolve . process . path . split ( path . delimiter ) ;
912+ for ( let i = 0 ; i < paths . length ; i ++ ) {
913+ paths [ i ] = resolver . resolve ( ws , paths [ i ] ) ;
914+ }
915+ }
916+ result . process = win32 . findExecutable (
917+ resolver . resolve ( ws , toResolve . process . name ) ,
918+ toResolve . process . cwd !== void 0 ? resolver . resolve ( ws , toResolve . process . cwd ) : undefined ,
919+ paths
920+ ) ;
901921 }
902- return result ;
922+ return Promise . resolve ( result ) ;
903923 }
904924
905925 private nextHandle ( ) : number {
0 commit comments