defaultConsumerWrapperName function
Default wrapper-name resolver.
Returns the basename (without .dart) of the consumer wrapper auto-
delegation should dispatch against. Probes bin/dispatcher.dart first
(canonical post-0.0.2 scaffold output), falls back to bin/artisan.dart
(legacy name still accepted for hand-curated wrappers), returns null
when neither is present.
Routing the resolved name into the delegate token keeps the
dart run :<name> lookup aligned with the file actually on disk:
a legacy-only
consumer dispatches via :artisan, a canonical-scaffold consumer via
:dispatcher. Without this name-aware resolution the delegate would
always pick :dispatcher and break on legacy consumers.
cwd defaults to Directory.current; tests inject a temp-dir path to
drive the check deterministically without touching the host filesystem.
Implementation
String? defaultConsumerWrapperName({String? cwd}) {
final base = cwd ?? Directory.current.path;
if (File(p.join(base, 'bin', 'dispatcher.dart')).existsSync()) {
return 'dispatcher';
}
if (File(p.join(base, 'bin', 'artisan.dart')).existsSync()) {
return 'artisan';
}
return null;
}