nearest method

String? nearest(
  1. String fileName
)

Implementation

String? nearest(String fileName) {
  Directory? directory = fs.currentDirectory;

  // traverse up the directory tree until we find a scripts.yaml file
  File? file;

  while (directory != null) {
    final possible = directory.childFile(fileName);
    if (possible.existsSync()) {
      file = possible;
      break;
    }

    if (directory.path == directory.parent.path) {
      break;
    }

    directory = directory.parent;
  }

  return file?.path;
}