fromFile static method

ConfigurationSource fromFile(
  1. String filePath
)

Parses a configuration from a file.

Implementation

static ConfigurationSource fromFile(
  final String filePath,
) {
  if (filePath.endsWith('.json')) {
    return fromString(
      _loadFile(filePath),
      format: ConfigEncoding.json,
    );
  } else if (filePath.endsWith('.yaml') || filePath.endsWith('.yml')) {
    return fromString(
      _loadFile(filePath),
      format: ConfigEncoding.yaml,
    );
  }
  throw UnsupportedError('Unsupported file extension: $filePath');
}