import * as vscode from "vscode" ; var exec = require ( "child_process" ) . exec ; export async function execute ( command ) { return new Promise < string > ( ( fulfill , reject ) => { exec ( command , function ( err , stdout , _ ) { if ( err !== null ) { reject ( err ) ; } else { fulfill ( stdout ) ; } } ) ; } ) ; } export enum Names { generatedFileName = "r.g.dart" , flr = "flr" , pubspec = "pubspec.yaml" , settings = "settings.json" } export enum Commands { init = "flr.init" , openFile = "flr.openFile" , refresh = "flr.regenerated" , startMonotor = "flr.startMonitor" , stopMonitor = "flr.stopMonitor" } export enum ControlFlags { isPubspecYamlExist = "isPubspecYamlExist" , isMonitorEnabled = "isMonitorEnabled" } export function switchControl ( flag , toValue ) { vscode . commands . executeCommand ( "setContext" , flag , toValue ) ; } export function registerCommandNice ( context , commandId , run ) { context . subscriptions . push ( vscode . commands . registerCommand ( commandId , run ) ) ; } export function firstWorkSpace ( ) { let folders = vscode . workspace . workspaceFolders ; if ( folders && folders . length > 0 ) { return folders [ 0 ] . uri ; } return undefined ; } export function distictArray < T > ( value ) { return value . filter ( ( n , i ) => value . indexOf ( n ) === i ) ; } export function caseInsensitiveComparator ( valueA , valueB ) { if ( valueA < valueB ) { return - 1 ; } else if ( valueA > valueB ) { return 1 ; } else { return 0 ; } }