removeStaleNativeAssetsHook function
Removes a stale generated hook (+ vendored runtime) when the plugin is no
longer on the native-assets path, so it can't double-bundle with the _dylib
build. Sentinel-gated (never touches a hand-written hook). Returns the
removed paths, relative to baseDir.
Implementation
List<String> removeStaleNativeAssetsHook(String baseDir) {
final removed = <String>[];
if (!hasGeneratedNativeAssetsHook(baseDir)) return removed;
File(p.join(baseDir, 'hook', 'build.dart')).deleteSync();
removed.add(p.join('hook', 'build.dart'));
final hookDir = Directory(p.join(baseDir, 'hook'));
if (hookDir.existsSync() && hookDir.listSync().isEmpty) hookDir.deleteSync();
final vendored = Directory(p.join(baseDir, 'src', 'nitro_native'));
if (vendored.existsSync()) {
vendored.deleteSync(recursive: true);
removed.add(p.join('src', 'nitro_native'));
}
return removed;
}