Use a temp directory

This commit is contained in:
creeper123123321 2021-05-08 09:23:20 -03:00
parent d90f59d7e9
commit a85d42bbe7

View File

@ -1,6 +1,6 @@
import org.gradlewebtools.minify.minifier.js.JSMinifierOptions
import org.jetbrains.kotlin.gradle.internal.ensureParentDirsCreated
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.nio.file.Files as JFiles
plugins {
`java-library`
@ -109,15 +109,13 @@ class JsMinifyFilter(reader: java.io.Reader) : java.io.FilterReader("".reader())
val minifier = org.gradlewebtools.minify.minifier.js.JsMinifier(
minifierOptions = JSMinifierOptions(originalFileNames = true)
)
val file = File.createTempFile("viaaas-minify-", ".js").also {
it.parentFile.ensureParentDirsCreated()
it.ensureParentDirsCreated()
it.createNewFile()
val file = JFiles.createTempDirectory("via-").resolve("tmp-minify.js").toFile().also {
it.writeText(reader.readText())
}
minifier.minify(file.parentFile, file.parentFile)
`in` = file.readText(Charsets.UTF_8).reader()
file.delete()
file.parentFile.delete()
}
constructor() : this("".reader())