11import org.jetbrains.compose.internal.de.undercouch.gradle.tasks.download.Download
2+ import org.jetbrains.kotlin.konan.properties.suffix
23import kotlin.text.replace
34
45plugins {
@@ -44,7 +45,9 @@ tasks.register<Download>("includeP5jsExamples"){
4445 from(zipTree(examples)){ // remove top level directory
4546 include(" */src/content/examples/en/**/*" )
4647 exclude(" **/description.mdx" )
47- eachFile { relativePath = RelativePath (true , * relativePath.segments.drop(5 ).toTypedArray()) }
48+ eachFile{
49+ relativePath = RelativePath (true , * relativePath.segments.drop(5 ).toTypedArray())
50+ }
4851 eachFile{
4952 if (name != " code.js" ){ return @eachFile }
5053
@@ -58,6 +61,16 @@ tasks.register<Download>("includeP5jsExamples"){
5861 if (parentName == name.removeSuffix(" .js" )){ return @eachFile }
5962 relativePath = RelativePath (true , * relativePath.segments.dropLast(1 ).toTypedArray(), name.removeSuffix(" .js" ), name)
6063 }
64+ // if a sketch folder starts with a digit, remove that digit and the following dash
65+ eachFile {
66+ val parent = this .file.parentFile
67+ val parentName = parent.name
68+ val regex = Regex (" ^\\ d+_" )
69+ if (regex.containsMatchIn(parentName)){
70+ val newParentName = parentName.replace(regex, " " )
71+ relativePath = RelativePath (true , * relativePath.segments.dropLast(2 ).toTypedArray(), newParentName, newParentName.suffix(" js" ))
72+ }
73+ }
6174 }
6275 into(layout.buildDirectory.dir(" mode/examples/Basics" ))
6376 }
0 commit comments