diff --git a/Sources/TuistKit/Mappers/Workspace/TuistWorkspaceRenderMarkdownMapper.swift b/Sources/TuistKit/Mappers/Workspace/TuistWorkspaceRenderMarkdownMapper.swift index 61ac8079d30..cf674b93cc2 100644 --- a/Sources/TuistKit/Mappers/Workspace/TuistWorkspaceRenderMarkdownMapper.swift +++ b/Sources/TuistKit/Mappers/Workspace/TuistWorkspaceRenderMarkdownMapper.swift @@ -5,13 +5,9 @@ import TuistSupport /// Tuist Workspace Markdown render Mapper. /// /// A mapper that includes a .xcodesample.plist file within the generated xcworkspace directory. -/// This is used to render markdown inside the de workspace. +/// This is used to render markdown inside the workspace. final class TuistWorkspaceRenderMarkdownReadmeMapper: WorkspaceMapping { func map(workspace: WorkspaceWithProjects) throws -> (WorkspaceWithProjects, [SideEffectDescriptor]) { - guard workspace.workspace.generationOptions.renderMarkdownReadme else { - return (workspace, []) - } - let tuistGeneratedFileDescriptor = FileDescriptor( path: workspace .workspace @@ -19,7 +15,8 @@ final class TuistWorkspaceRenderMarkdownReadmeMapper: WorkspaceMapping { .appending( component: ".xcodesamplecode.plist" ), - contents: try PropertyListEncoder().encode([String]()) + contents: try PropertyListEncoder().encode([String]()), + state: workspace.workspace.generationOptions.renderMarkdownReadme ? .present : .absent ) return (workspace, [ diff --git a/Tests/TuistKitTests/Mappers/Workspace/TuistWorkspaceRenderMarkdownReadmeMapperTests.swift b/Tests/TuistKitTests/Mappers/Workspace/TuistWorkspaceRenderMarkdownReadmeMapperTests.swift index 72716a88708..6d99cd7f881 100644 --- a/Tests/TuistKitTests/Mappers/Workspace/TuistWorkspaceRenderMarkdownReadmeMapperTests.swift +++ b/Tests/TuistKitTests/Mappers/Workspace/TuistWorkspaceRenderMarkdownReadmeMapperTests.swift @@ -68,6 +68,15 @@ final class TuistWorkspaceRenderMarkdownReadmeMapperTests: TuistUnitTestCase { renderMarkdownReadme: false )) + let tuistGeneratedFileDescriptor = FileDescriptor( + path: workspace + .xcWorkspacePath + .appending( + component: ".xcodesamplecode.plist" + ), + contents: try PropertyListEncoder().encode([String]()), + state: .absent // file should be deleted + ) let workspaceWithProjects = WorkspaceWithProjects(workspace: workspace, projects: []) // When let (gotWorkspaceWithProjects, sideEffects) = try TuistWorkspaceRenderMarkdownReadmeMapper() @@ -78,6 +87,11 @@ final class TuistWorkspaceRenderMarkdownReadmeMapperTests: TuistUnitTestCase { gotWorkspaceWithProjects.workspace.generationOptions.renderMarkdownReadme ) XCTAssertTrue(gotWorkspaceWithProjects.workspace.projects.isEmpty) - XCTAssertEqual(sideEffects, []) + XCTAssertEqual( + sideEffects, + [ + .file(tuistGeneratedFileDescriptor), + ] + ) } }