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;

  homeDir = Platform.isWindows ? Platform.environment['USERPROFILE'] ?? '' : 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);
}