/**
 *****************************************
 * Created by edonet@163.com
 * Created on 2020-05-30 20:05:28
 *****************************************
 */ 'use strict' ; /**
 *****************************************
 * 加载依赖
 *****************************************
 */ import * as vscode from 'vscode' ; import Command , { TerminalOptions } from './Command' ; /**
 *****************************************
 * 命令配置
 *****************************************
 */ export interface CommandOptions { cmd ? : string ; command ? : string ; terminal ? : string | TerminalOptions ; appendExplorerSelectedFiles ? : boolean ; } /**
 *****************************************
 * 激活扩展
 *****************************************
 */ export function activate ( context ) { context . subscriptions . push ( vscode . commands . registerCommand ( 'command-runner.run' , async ( opts = { } , files ? ) => { const command = new Command ( context ) ; const cmd = opts . command || opts . cmd || '' ; if ( typeof opts . terminal === 'string' ) { opts . terminal = { name : opts . terminal } ; } if ( files && files . length ) { files . forEach ( argv => command . addFile ( argv . fsPath ) ) ; } else if ( opts . appendExplorerSelectedFiles ) { await vscode . commands . executeCommand ( 'copyFilePath' ) ; const clipboardFiles = await vscode . env . clipboard . readText ( ) ; clipboardFiles . split ( /\r?\n/ ) . forEach ( f => command . addFile ( f ) ) ; } if ( cmd ) { return command . execute ( command . commands [ cmd ] || cmd , opts . terminal ) ; } command . pick ( ) ; } ) ) ; context . subscriptions . push ( vscode . commands . registerCommand ( 'command-runner.runInTerminal' , ( { terminal } = { } ) => { const command = new Command ( context ) ; if ( typeof terminal === 'string' ) { terminal = { name : terminal } ; } command . executeSelectText ( terminal ) ; } ) ) ; }