startDetachedWatcher function

Future<void> startDetachedWatcher(
  1. File yamlFile
)

Start a detached watcher for the given YAML file

Implementation

Future<void> startDetachedWatcher(File yamlFile) async {
  final hash = _hashForYaml(yamlFile);

  final existingPids = await _getWatcherPids(yamlFile);
  if (existingPids.isNotEmpty) {
    print('Watcher already running for ${yamlFile.path} (PIDs: ${existingPids.join(',')})');
    return;
  }

  // Start the detached watcher with the hash as identifier
  await Process.start('commands', ['--watch', '--watch-id', hash], mode: ProcessStartMode.detached);

  print('Detached watcher started for ${yamlFile.path}');
}