Skip to content

Commit c53c98d

Browse files
committed
Improve git exporter
1 parent 3f437da commit c53c98d

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/main/kotlin/net/theevilreaper/stelaris/cli/exporter/GitProjectExporter.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider
88
import java.nio.file.Files
99
import java.nio.file.Path
1010
import java.nio.file.StandardCopyOption
11+
import java.util.zip.ZipInputStream
1112

1213
class GitProjectExporter(
1314
private val generationFolder: Path,
@@ -32,7 +33,23 @@ class GitProjectExporter(
3233
}
3334

3435
override fun export() {
35-
// Files.copy(templateStream, generationFolder, StandardCopyOption.REPLACE_EXISTING)
36+
val zipStream = javaClass.getClassLoader().getResourceAsStream("flutter_template.zip")
37+
ZipInputStream(zipStream).use { zis ->
38+
var entry = zis.nextEntry
39+
while (entry != null) {
40+
val newPath = generationFolder.resolve(entry.name)
41+
42+
if (entry.isDirectory) {
43+
Files.createDirectories(newPath)
44+
} else {
45+
Files.createDirectories(newPath.parent)
46+
Files.copy(zis, newPath, StandardCopyOption.REPLACE_EXISTING)
47+
}
48+
49+
zis.closeEntry()
50+
entry = zis.nextEntry
51+
}
52+
}
3653

3754
val gitRepo = Git.init().setDirectory(generationFolder.toFile()).call()
3855

0 commit comments

Comments
 (0)