Skip to content

Commit 420310e

Browse files
committed
fixed examples within More folders
1 parent 5e822b2 commit 420310e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

p5js/build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.jetbrains.compose.internal.de.undercouch.gradle.tasks.download.Download
2+
import kotlin.text.replace
23

34
plugins {
45
kotlin("jvm") version libs.versions.kotlin
@@ -42,13 +43,21 @@ tasks.register<Download>("includeP5jsExamples"){
4243
copy{
4344
from(zipTree(examples)){ // remove top level directory
4445
include("*/src/content/examples/en/**/*")
46+
exclude("**/description.mdx")
4547
eachFile { relativePath = RelativePath(true, *relativePath.segments.drop(5).toTypedArray()) }
4648
eachFile{
4749
if(name != "code.js"){ return@eachFile }
4850

4951
val parentName = this.file.parentFile.name
5052
name = "$parentName.js"
5153
}
54+
eachFile {
55+
// if the file is .js and not in a directory named of itself, move it to such a directory
56+
if(!name.endsWith(".js")){ return@eachFile}
57+
val parentName = this.file.parentFile.name
58+
if(parentName == name.removeSuffix(".js")){ return@eachFile }
59+
relativePath = RelativePath(true, *relativePath.segments.dropLast(1).toTypedArray(), name.removeSuffix(".js"), name)
60+
}
5261
}
5362
into(layout.buildDirectory.dir("mode/examples/Basics"))
5463
}

0 commit comments

Comments
 (0)