writeDirectly method

Future<void> writeDirectly(
  1. String filePath,
  2. String content
)

Write guidelines to a specific file path

Low-level method that writes content directly to a file without smart merging. Useful for testing or special cases.

Parameters:

  • filePath: Full path to the file to write
  • content: Content to write

Throws GuidelineWriteException if writing fails.

Implementation

Future<void> writeDirectly(String filePath, String content) async {
  try {
    final file = File(filePath);
    final directory = Directory(p.dirname(filePath));

    // Create directory if it doesn't exist
    if (!await directory.exists()) {
      await directory.create(recursive: true);
    }

    await file.writeAsString(content);
  } catch (e) {
    throw GuidelineWriteException(
      'Failed to write file: $e',
      filePath,
    );
  }
}