runFile function

void runFile(
  1. String path
)

Implementation

void runFile(String path) {
  try {
    final file = File(path);
    final source = file.readAsStringSync();
    run(source, isRepl: false);
    if (hadError) exit(65); // Indicate syntax error exit code
    if (hadRuntimeError) exit(70); // Indicate runtime error exit code
  } catch (e) {
    print("Error reading file '$path': $e");
    exit(1);
  }
}