getConfigPath method

String getConfigPath({
  1. ConfigScope scope = ConfigScope.global,
  2. String? projectRoot,
})

Return the canonical file path for a configuration scope.

Implementation

String getConfigPath({
  ConfigScope scope = ConfigScope.global,
  String? projectRoot,
}) {
  switch (scope) {
    case ConfigScope.global:
      final home =
          Platform.environment['HOME'] ??
          Platform.environment['USERPROFILE'] ??
          '.';
      return '$home/.neomage/config.json';
    case ConfigScope.project:
      final root = projectRoot ?? Directory.current.path;
      return '$root/.neomage/config.json';
    case ConfigScope.session:
      return ''; // session config is ephemeral
  }
}