readFile method

String readFile(
  1. String path
)

Reads a file's content as a string.

Implementation

String readFile(String path) {
  try {
    final file = File(path);
    if (!file.existsSync()) {
      throw CliException('File does not exist at $path');
    }
    return file.readAsStringSync();
  } catch (e) {
    throw CliException('Failed to read file from $path', e);
  }
}