isWindowsCppModule function

bool isWindowsCppModule(
  1. File specFile
)

Returns true when the spec file uses direct C++ for Windows only. Windows C++ modules use windows/CMakeLists.txt (not the shared src/) and need their own impl stub created in windows/src/.

Implementation

bool isWindowsCppModule(File specFile) {
  final content = specFile.readAsStringSync();
  final annotationMatch = RegExp(r'@NitroModule\s*\(([^)]+)\)', dotAll: true).firstMatch(content);
  if (annotationMatch == null) return false;
  final annotation = annotationMatch.group(1)!.replaceAll('\n', ' ');
  return RegExp(
    r'\bwindows\s*:\s*(?:NativeImpl|WindowsNativeImpl)\.cpp\b',
  ).hasMatch(annotation);
}