warnIfComments method

bool warnIfComments(
  1. File file
)

Says that comments are about to be lost. Returns whether it warned.

A wizard calls this before its own confirm, so the user makes one informed decision instead of answering two questions in a row.

Implementation

bool warnIfComments(File file) {
  if (!file.existsSync()) return false;
  if (!_hasComments(file.readAsStringSync())) return false;
  logger.logWarning(
    'rewriting ${file.path} will drop its comments and reformat it',
  );
  return true;
}