import * as cp from "child_process" ; import { CancellationToken , extensions , QuickPickOptions , window } from "vscode" ; import TaskItem from "../tree/item" ; export function findIdInTaskMap ( id , taskMap ) { let found = 0 ; for ( const [ k , task ] of taskMap ) { if ( task . id ?. includes ( id ) && ! task . isUser ) { found ++ ; } } return found ; } export function spawn ( command , args ? , options ? ) { let proc ; if ( options ) { proc = cp . spawn ( command , args || [ ] , options ) ; } else { proc = cp . spawn ( command , args || [ ] ) ; } return proc ; } export function activeExtension ( ) { return new Promise < void > ( ( resolve , reject ) => { const extension = extensions . getExtension ( "spmeesseman.vscode-taskexplorer" ) ; if ( ! extension ) { reject ( ) ; return ; } if ( ! extension . isActive ) { extension . activate ( ) . then ( ( ) => resolve ( ) , ( ) => reject ( ) ) ; } else { resolve ( ) ; } } ) ; } const overridesShowInputBox = [ ] ; export function overrideNextShowInputBox ( value ) { overridesShowInputBox . push ( value ) ; } const originalShowInputBox = window . showInputBox ; window . showInputBox = ( ... args ) => { const next = overridesShowInputBox . shift ( ) ; if ( typeof next === "undefined" ) { return originalShowInputBox . call ( null , args as any ) ; } return new Promise ( ( resolve , reject ) => { resolve ( next ) ; } ) ; } ;