Use stream instead of zip file
This commit is contained in:
@@ -3,22 +3,19 @@ package starter
|
||||
import starter.templates.Template
|
||||
import starter.utils.ZipOutput
|
||||
import starter.utils.sanitizeFilename
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
class ProjectZip(private val templates: List<Template>) {
|
||||
|
||||
fun createZip(project: Project): String {
|
||||
val name: String
|
||||
|
||||
fun createZip(project: Project): ByteArrayOutputStream {
|
||||
val projectName = sanitizeFilename(project.name)
|
||||
ZipOutput(projectName).use { zip ->
|
||||
name = zip.name
|
||||
|
||||
val zipOutput = ZipOutput()
|
||||
zipOutput.use { zip ->
|
||||
templates.filter { it.enabled(project) }.forEach { template ->
|
||||
zip.write(projectName + "/" + template.path(project), template.render(project))
|
||||
}
|
||||
}
|
||||
|
||||
return name
|
||||
return zipOutput.outputStream
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user