Skip to content

Commit

Permalink
feat: allow help to be shown from anywhere (#405)
Browse files Browse the repository at this point in the history
Signed-off-by: Sahil Soni <[email protected]>
Co-authored-by: Gabriel Terwesten <[email protected]>
  • Loading branch information
SscSPs and blaugold authored Oct 17, 2022
1 parent 9ea87a3 commit d754055
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/melos/bin/melos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ Future<void> main(List<String> arguments) async {
return;
}
try {
final config = await MelosWorkspaceConfig.fromDirectory(Directory.current);
final config = shouldUseEmptyConfig(arguments)
? MelosWorkspaceConfig.empty()
: await MelosWorkspaceConfig.fromDirectory(Directory.current);
await MelosCommandRunner(config).run(arguments);
} on MelosException catch (err) {
stderr.writeln(err.toString());
Expand All @@ -53,3 +55,10 @@ Future<void> main(List<String> arguments) async {
rethrow;
}
}

bool shouldUseEmptyConfig(List<String> arguments) {
final willShowHelp = arguments.isEmpty ||
arguments.contains('--help') ||
arguments.contains('-h');
return willShowHelp;
}
8 changes: 8 additions & 0 deletions packages/melos/lib/src/workspace_configs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,14 @@ class MelosWorkspaceConfig {
: CommandConfigs.empty,
);

MelosWorkspaceConfig.empty()
: this(
name: 'Melos',
packages: [],
path: Directory.current.path,
commands: CommandConfigs.empty,
);

static Directory? _searchForAncestorDirectoryWithMelosYaml(Directory from) {
for (var testedDirectory = from;
testedDirectory.path != testedDirectory.parent.path;
Expand Down

0 comments on commit d754055

Please sign in to comment.