blueprintFormatOf function

BlueprintFormat blueprintFormatOf(
  1. String path
)

The format a file extension names.

Anything that is not .yaml/.yml is read as JSON — the wire's own format, and the right assumption for a file with no extension at all.

Implementation

BlueprintFormat blueprintFormatOf(String path) {
  final dot = path.lastIndexOf('.');
  final extension = dot == -1 ? '' : path.substring(dot).toLowerCase();
  return extension == '.yaml' || extension == '.yml'
      ? BlueprintFormat.yaml
      : BlueprintFormat.json;
}