Files
nixpkgs/pkgs/by-name/me/melos/add-generic-main.patch
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

51 lines
1.3 KiB
Diff

diff --git a/bin/melos.dart b/bin/melos.dart
index 0db7013..218276f 100644
--- a/bin/melos.dart
+++ b/bin/melos.dart
@@ -1,11 +1,37 @@
+import 'dart:io';
import 'package:cli_launcher/cli_launcher.dart';
import 'package:melos/src/command_runner.dart';
-Future<void> main(List<String> arguments) async => launchExecutable(
- arguments,
- LaunchConfig(
- name: ExecutableName('melos'),
- launchFromSelf: false,
- entrypoint: melosEntryPoint,
- ),
-);
+Future<void> main(List<String> arguments) async {
+ final melosYamlPath = findMelosYaml();
+
+ if (melosYamlPath == null) {
+ print('Error: melos.yaml not found in the project.');
+ // Handle the error as needed
+ return;
+ }
+
+ melosEntryPoint(
+ arguments,
+ LaunchContext(
+ directory: Directory.current,
+ localInstallation: ExecutableInstallation(
+ name: ExecutableName('melos'),
+ isSelf: false,
+ packageRoot: melosYamlPath,
+ ),
+ ),
+ );
+}
+
+Directory? findMelosYaml() {
+ var directory = Directory.current;
+ while (directory.path != directory.parent.path) {
+ final melosYamlPath = '${directory.path}/melos.yaml';
+ if (File(melosYamlPath).existsSync()) {
+ return directory;
+ }
+ directory = directory.parent;
+ }
+ return null;
+}