private async Task <string> RollbackAsync() { string path = _repo.GetBackupFilePath(); string jsonBackup = await ReadFromFileAsync(_repo.GetBackupConfigPath()); Dictionary <string, string> backupDict = JsonHelper.ToDictionary(jsonBackup); string currentFile = await ReadFromFileAsync(path); FluentFunctionsReplacer fluentFunctionsReplacer = new FluentFunctionsReplacer(currentFile); string result = fluentFunctionsReplacer.ReplaceFunctions(backupDict); await SaveToFileAsync(path, result); return(result); }
private async Task <string> ReplaceAllAsync() { bool createBackup = _repo.HasBackup; string result = null; foreach (var path in _repo.GetPaths()) { if (ExistConfigFile(path)) { string currentFile = await ReadFromFileAsync(path); FluentFunctionsReplacer fluentFunctionsReplacer = new FluentFunctionsReplacer(currentFile, createBackup); result = fluentFunctionsReplacer.ReplaceFunctions(_repo.GetEnviroment()); await SaveToFileAsync(path, result); if (createBackup) { string json = JsonHelper.ToJson(fluentFunctionsReplacer.Backup); await SaveToFileAsync(_repo.FindBackupPath(path), json); } } } return(result); }