determineOutputPath method

String determineOutputPath()

Implementation

String determineOutputPath() {
  if (config.outputDirectory != null) {
    // output directory specified, use this path instead
    return '${config.outputDirectory!}/${config.outputFileName}';
  } else {
    // use the directory of the first (random) translation file
    final tempPath = files.first.path;
    if (config.flutterIntegration && !tempPath.startsWith('lib/')) {
      // In Flutter environment, only files inside 'lib' matter
      // Generate to lib/gen/<fileName> by default.
      return 'lib/gen/${config.outputFileName}';
    } else {
      // By default, generate to the same directory as the translation file
      return PathUtils.replaceFileName(
        path: tempPath,
        newFileName: config.outputFileName,
        pathSeparator: '/',
      );
    }
  }
}