getDefaultCacheDirectory static method

String getDefaultCacheDirectory()

Returns the default cache directory based on the user's platform.

Implementation

static String getDefaultCacheDirectory() {
  const defaultCacheDirectoryName = '.cached_build_runner';
  String homeDir;

  if (Platform.isWindows) {
    homeDir = Platform.environment['USERPROFILE'] ?? '';
  } else {
    homeDir = Platform.environment['HOME'] ?? '';
  }

  if (homeDir.isEmpty) {
    reportError(
      'Could not set default cache directory. Please use the --cache-directory flag to provide a cache directory.',
    );
  }

  return path.join(path.normalize(homeDir), defaultCacheDirectoryName);
}