in src/algebraic-types.ts [280:339]
export function generate(
directoryRunFrom: string,
optionalConfigPath: string | undefined,
parsedArgs: CommandLine.Arguments,
): Promise.Future<List.List<WriteFileUtils.ConsoleOutputResults>> {
const promises = parsedArgs.givenPaths.map((givenPath) => {
const requestedPath: File.AbsoluteFilePath =
PathUtils.getAbsolutePathFromDirectoryAndAbsoluteOrRelativePath(
File.getAbsoluteFilePath(directoryRunFrom),
givenPath,
);
const outputPath: File.AbsoluteFilePath | null = outputDirectory(
directoryRunFrom,
parsedArgs.outputPath,
);
const configPath = optionalConfigPath
? FileFinder.findConfigAtPath(
File.getAbsoluteFilePath(optionalConfigPath),
)
: FileFinder.searchForConfig('.algebraicTypeConfig', requestedPath);
const algebraicTypeCreationContextFuture = getAlgebraicTypeCreationContext(
configPath,
parsedArgs,
);
const readFileSequence = ReadFileUtils.loggedSequenceThatReadsFiles(
requestedPath,
'adtValue',
);
const parsedSequence = LoggingSequenceUtils.mapLoggedSequence(
readFileSequence,
parseValues,
);
const options: GenerationOptions = {
outputPath: outputPath,
outputFlags: parsedArgs.outputFlags,
};
const pluginProcessedSequence = LoggingSequenceUtils.mapLoggedSequence(
parsedSequence,
(either) =>
processAlgebraicTypeCreationRequest(
options,
algebraicTypeCreationContextFuture,
either,
),
);
return WriteFileUtils.evaluateObjectFileWriteRequestSequence(
parsedArgs,
pluginProcessedSequence,
);
});
return Promise.all(List.fromArray(promises));
}