Skip to content

Commit 1f840af

Browse files
authored
Refactor unique command logic to created at the location it's used (#407)
Makes a number of function calls more simple
1 parent 6484ebb commit 1f840af

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

mono_repo/lib/src/commands/github/generate.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ class _GeneratedGitHubConfig {
5252
_GeneratedGitHubConfig._(this.workflowFiles);
5353

5454
factory _GeneratedGitHubConfig.generate(RootConfig rootConfig) {
55-
final commandsToKeys = extractCommands(rootConfig);
56-
57-
final result = generateGitHubYml(rootConfig, commandsToKeys);
58-
55+
final result = generateGitHubYml(rootConfig);
5956
return _GeneratedGitHubConfig._(result);
6057
}
6158
}

mono_repo/lib/src/commands/github/github_yaml.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ import 'step.dart';
1919

2020
const _onCompletionStage = '_on_completion';
2121

22-
Map<String, String> generateGitHubYml(
23-
RootConfig rootConfig,
24-
Map<String, String> commandsToKeys,
25-
) {
22+
Map<String, String> generateGitHubYml(RootConfig rootConfig) {
2623
final jobs = <HasStageName>[
2724
...rootConfig.expand((config) => config.jobs),
2825
];
@@ -79,7 +76,6 @@ Map<String, String> generateGitHubYml(
7976
final allJobs = _listJobs(
8077
rootConfig,
8178
sortedJobs,
82-
commandsToKeys,
8379
rootConfig.monoConfig.mergeStages,
8480
rootConfig.monoConfig.github.onCompletion,
8581
rootConfig.monoConfig.githubConditionalStages,
@@ -175,7 +171,6 @@ ${toYaml({'jobs': jobList})}
175171
Iterable<_MapEntryWithStage> _listJobs(
176172
RootConfig rootConfig,
177173
List<HasStageName> jobs,
178-
Map<String, String> commandsToKeys,
179174
Set<String> mergeStages,
180175
List<Job>? onCompletionJobs,
181176
Map<String, ConditionalStage> conditionalStages,
@@ -206,6 +201,8 @@ Iterable<_MapEntryWithStage> _listJobs(
206201

207202
final ciJob = job as CIJob;
208203

204+
final commandsToKeys = extractCommands(rootConfig);
205+
209206
final commands =
210207
ciJob.tasks.map((task) => commandsToKeys[task.command]!).toList();
211208

0 commit comments

Comments
 (0)