Skip to content

Commit e659bd9

Browse files
authored
Add ZipSource.fromSeqPath (#352)
This enables something like this `os.zip(dest / "docusaurus.zip", os.list(wd / "build"))`
1 parent cf2e9a6 commit e659bd9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

os/src/ZipOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,10 @@ object zip {
219219
class ZipSource private[os] (val src: os.Path, val dest: Option[os.SubPath])
220220
object ZipSource {
221221
implicit def fromPath(src: os.Path): ZipSource = new ZipSource(src, None)
222+
implicit def fromSeqPath(srcs: Seq[os.Path]): Seq[ZipSource] = srcs.map(fromPath)
222223
implicit def fromPathTuple(tuple: (os.Path, os.SubPath)): ZipSource =
223224
new ZipSource(tuple._1, Some(tuple._2))
224225
}
225-
226226
}
227227

228228
object unzip {

os/test/src/ZipOpTests.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,17 @@ object ZipOpTests extends TestSuite {
176176
assert(paths == expected)
177177
}
178178

179+
test("zipList") - prep { wd =>
180+
val sources = wd / "folder1"
181+
val zipFilePath = os.zip(
182+
dest = wd / "my.zip",
183+
sources = os.list(sources)
184+
)
185+
186+
val expected = os.unzip.list(source = zipFilePath).map(_.resolveFrom(sources)).toSet
187+
assert(os.list(sources).toSet == expected)
188+
}
189+
179190
test("unzipStream") - prep { wd =>
180191
// Step 1: Create an in-memory ZIP file as a stream
181192
val zipStreamOutput = new ByteArrayOutputStream()

0 commit comments

Comments
 (0)