setbfree: 0.8.12 -> 0.8.13 (#372025)
[NixPkgs.git] / pkgs / by-name / me / melos / add-generic-main.patch
blob6871a4f7c6fae933c654dc61af61aeb626e37062
1 diff --git a/bin/melos.dart b/bin/melos.dart
2 index 0db7013..218276f 100644
3 --- a/bin/melos.dart
4 +++ b/bin/melos.dart
5 @@ -1,11 +1,37 @@
6 +import 'dart:io';
7 import 'package:cli_launcher/cli_launcher.dart';
8 import 'package:melos/src/command_runner.dart';
10 -Future<void> main(List<String> arguments) async => launchExecutable(
11 - arguments,
12 - LaunchConfig(
13 +Future<void> main(List<String> arguments) async {
14 + final melosYamlPath = findMelosYaml();
16 + if (melosYamlPath == null) {
17 + print('Error: melos.yaml not found in the project.');
18 + // Handle the error as needed
19 + return;
20 + }
22 + melosEntryPoint(
23 + arguments,
24 + LaunchContext(
25 + directory: Directory.current,
26 + localInstallation: ExecutableInstallation(
27 name: ExecutableName('melos'),
28 - launchFromSelf: false,
29 - entrypoint: melosEntryPoint,
30 + isSelf: false,
31 + packageRoot: melosYamlPath,
33 - );
34 + ),
35 + );
38 +Directory? findMelosYaml() {
39 + var directory = Directory.current;
40 + while (directory.path != directory.parent.path) {
41 + final melosYamlPath = '${directory.path}/melos.yaml';
42 + if (File(melosYamlPath).existsSync()) {
43 + return directory;
44 + }
45 + directory = directory.parent;
46 + }
47 + return null;