private string prepareOutputDirectory(GenerationSettings settings, Template template) { // cleanup the output directory var destinationPath = Path.Join(settings.OutputDirectory, template.OutputRelativePath); if (template.IsStub && !settings.ProcessTemplateStubs) { // don't clean the directory if we're not going to ProcessTemplateStubs // this way, we can be sneaky and still generate stubs that don't already exist return(destinationPath); } if (!template.DeleteAllItemsInOutputDirectory) { // don't clean the directory if DeleteAllItemsInOutputDirectory is set to false // this way a directory may contain elements that shouldn't be deleted. // This is not preferred, but it gives us flexibility. return(destinationPath); } var destinationDirectory = Path.GetDirectoryName(destinationPath); if (template.DeleteAllItemsInOutputDirectory) { var cleanupResult = _templateOutputEngine.CleanupOutputDirectory(destinationDirectory); } return(destinationPath); }
private OperationResult createFilesAndDirectories(string sourcePath, string destinationPath) { // cleanup the output directory var cleanupResult = _templateOutputEngine.CleanupOutputDirectory(destinationPath); copyAllDirectories(sourcePath, destinationPath); copyAllFiles(sourcePath, destinationPath); return(OperationResult.Ok()); }