compare method
A method named compare
for comparing two files.
Implementation
@override
bool compare({
required String approvedPath,
required String receivedPath,
bool isLogError = true,
}) {
try {
final approved = ApprovalUtils.readFile(path: approvedPath)
.replaceAll('\r\n', '\n')
.trim();
final received = ApprovalUtils.readFile(path: receivedPath)
.replaceAll('\r\n', '\n')
.trim();
// Return true if contents of both files match exactly
return approved.compareTo(received) == 0;
} catch (e, st) {
if (isLogError) {
ApprovalLogger.exception("From FileComparator: $e", stackTrace: st);
}
rethrow;
}
}