24 lines
549 B
Kotlin
24 lines
549 B
Kotlin
package starter
|
|
|
|
import starter.templates.Template
|
|
import starter.utils.ZipOutput
|
|
import starter.utils.sanitizeFilename
|
|
|
|
class ProjectZip(private val templates: List<Template>) {
|
|
|
|
fun createZip(project: Project): String {
|
|
val name: String
|
|
|
|
ZipOutput(sanitizeFilename(project.name)).use { zip ->
|
|
name = zip.name
|
|
|
|
templates.filter { it.enabled(project) }.forEach { template ->
|
|
zip.write(template.path(project), template.render(project))
|
|
}
|
|
}
|
|
|
|
return name
|
|
}
|
|
|
|
}
|