Skip to content

Commit 81786a4

Browse files
authored
Merge branch 'main' into michael/with-temp-file
2 parents 7e6c994 + ed34e15 commit 81786a4

38 files changed

+2205
-1028
lines changed

.git-blame-ignore-revs

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
# Format the codebase for the first time
22
b049841d5707d5bd87be516d8cda7be2a7585eae
3+
4+
# Reformatted test code
5+
e437d63c40713e0645a4895bbe5a0fc565cd56db
6+

.github/workflows/build.yml

+16-12
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,25 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
os: [ubuntu-latest, windows-latest, macos-latest]
14+
os: [ubuntu-latest, windows-latest]
1515
java-version: [8, 17]
16+
include:
17+
- os: macos-latest
18+
java-version: 17
19+
- os: macos-latest
20+
java-version: 11
1621

1722
runs-on: ${{ matrix.os }}
1823

1924
steps:
20-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
2126
with:
2227
fetch-depth: 0
2328

24-
- uses: actions/setup-java@v3
29+
- uses: actions/setup-java@v4
2530
with:
2631
distribution: 'temurin'
2732
java-version: ${{ matrix.java-version }}
28-
2933
- name: Fetch millw launcher (Windows)
3034
run: curl -Lo mill.bat "https://raw.githubusercontent.com/lefou/millw/main/millw.bat"
3135
if: matrix.os == 'windows-latest'
@@ -38,11 +42,11 @@ jobs:
3842
check-bin-compat:
3943
runs-on: ubuntu-latest
4044
steps:
41-
- uses: actions/checkout@v3
45+
- uses: actions/checkout@v4
4246
with:
4347
fetch-depth: 0
4448

45-
- uses: actions/setup-java@v3
49+
- uses: actions/setup-java@v4
4650
with:
4751
distribution: 'temurin'
4852
java-version: 8
@@ -52,16 +56,16 @@ jobs:
5256
check-formatting:
5357
runs-on: ubuntu-latest
5458
steps:
55-
- uses: actions/checkout@v3
59+
- uses: actions/checkout@v4
5660
with:
5761
fetch-depth: 0
5862

59-
- uses: actions/setup-java@v3
63+
- uses: actions/setup-java@v4
6064
with:
6165
distribution: 'temurin'
62-
java-version: 8
66+
java-version: 17
6367

64-
- run: ./mill -i -k __.checkFormat
68+
- run: ./mill -i mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources
6569

6670
publish-sonatype:
6771
if: github.repository == 'com-lihaoyi/os-lib' && contains(github.ref, 'refs/tags/')
@@ -76,8 +80,8 @@ jobs:
7680
LC_MESSAGES: "en_US.UTF-8"
7781
LC_ALL: "en_US.UTF-8"
7882
steps:
79-
- uses: actions/checkout@v3
80-
- uses: actions/setup-java@v3
83+
- uses: actions/checkout@v4
84+
- uses: actions/setup-java@v4
8185
with:
8286
distribution: 'temurin'
8387
java-version: 8

.github/workflows/dependency-graph.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212

13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@v4
1414
with:
1515
fetch-depth: 0
1616

1717
- uses: coursier/cache-action@v6
1818

19-
- uses: actions/setup-java@v3
19+
- uses: actions/setup-java@v4
2020
with:
2121
distribution: 'temurin'
2222
java-version: '17'

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ target/
66
.project
77
.cache
88
.sbtserver
9+
.scala-build/
10+
.bsp/
911
project/.sbtserver
1012
tags
1113
nohup.out

.mill-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.10.12
1+
0.11.7-29-f2e220

.scalafmt.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "3.5.8"
1+
version = "3.8.1"
22

33
align.preset = none
44
align.openParenCallSite = false

Readme.adoc

+105-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
= OS-Lib
2-
:version: 0.9.1
3-
:toc-placement: preamble
4-
:toclevels: 3
5-
:toc:
2+
:version: 0.10.0
63
:link-geny: https://github.com/com-lihaoyi/geny
74
:link-oslib: https://github.com/com-lihaoyi/os-lib
85
:link-oslib-gitter: https://gitter.im/lihaoyi/os-lib
@@ -14,6 +11,7 @@
1411
image:{link-oslib}/actions/workflows/build.yml/badge.svg[Build Status,link={link-oslib}/actions]
1512
image:https://badges.gitter.im/Join%20Chat.svg[Gitter Chat,link={link-oslib-gitter}]
1613
image:https://img.shields.io/badge/patreon-sponsor-ff69b4.svg[Patreon,link=https://www.patreon.com/lihaoyi]
14+
image:https://javadoc.io/badge2/com.lihaoyi/os-lib_3/scaladoc.svg[API Docs (Scala 3),link=https://javadoc.io/doc/com.lihaoyi/os-lib_3]
1715

1816
[source,scala]
1917
----
@@ -86,6 +84,8 @@ ivy"com.lihaoyi::os-lib:{version}"
8684
"com.lihaoyi" %% "os-lib" % "{version}"
8785
----
8886

87+
https://javadoc.io/doc/com.lihaoyi/os-lib_3[API Documentation (Scala 3)]
88+
8989
== Cookbook
9090

9191
Most operation in OS-Lib take place on <<os-path>>s, which are
@@ -1128,7 +1128,7 @@ os.readLink(wd / "misc" / "broken-abs-symlink") ==> os.root / "doesnt" / "exist"
11281128
----
11291129

11301130
Note that symbolic links can be either absolute ``os.Path``s or relative
1131-
``os.RelPath``s, represented by `os.FilePath`. You can also use `os.readLink.all`
1131+
``os.RelPath``s, represented by `os.FilePath`. You can also use `os.readLink.absolute`
11321132
to automatically resolve relative symbolic links to their absolute destination:
11331133

11341134
[source,scala]
@@ -1483,7 +1483,7 @@ the subprocess via `os.SubProcess#stdin`, and if used on its stdout it lets the
14831483
parent process read from the subprocess via `os.SubProcess#stdout`
14841484
and `os.SubProcess#stderr`.
14851485
* `os.Inherit`: inherits the stream from the parent process. This lets the
1486-
subprocess read directly from the paren process's standard input or write
1486+
subprocess read directly from the parent process's standard input or write
14871487
directly to the parent process's standard output or error
14881488
* `os.Path`: connects the subprocess's stream to the given filesystem
14891489
path, reading its standard input from a file or writing its standard
@@ -1691,6 +1691,48 @@ val sha = os.proc("shasum", "-a", "256").spawn(stdin = gzip.stdout)
16911691
sha.stdout.trim ==> "acc142175fa520a1cb2be5b97cbbe9bea092e8bba3fe2e95afa645615908229e -"
16921692
----
16931693

1694+
== Spawning Pipelines of Subprocesses
1695+
1696+
After constructing a subprocess with `os.proc`, you can use the `pipeTo` method
1697+
to pipe its output to another subprocess:
1698+
1699+
[source,scala]
1700+
----
1701+
val wc = os.proc("ls", "-l")
1702+
.pipeTo(os.proc("wc", "-l"))
1703+
.call()
1704+
.out.text()
1705+
----
1706+
1707+
This is equivalent to the shell command `ls -l | wc -l`. You can chain together
1708+
as many subprocesses as you like. Note that by using this API you can utilize
1709+
the broken pipe behaviour of Unix systems. For example, you can take 10 first elements
1710+
of output from the `yes` command, and after the `head` command terminates, the `yes`
1711+
command will be terminated as well:
1712+
1713+
[source,scala]
1714+
----
1715+
val yes10 = os.proc("yes")
1716+
.pipeTo(os.proc("head", "-n", "10"))
1717+
.call()
1718+
.out.text()
1719+
----
1720+
1721+
This feature is implemented inside the library and will terminate any process reading the
1722+
stdin of other process in pipeline on every IO error. This behavior can be disabled via the
1723+
`handleBrokenPipe` flag on `call` and `spawn` methods. Note that Windows does not support
1724+
broken pipe behaviour, so a command like`yes` would run forever. `handleBrokenPipe` is set
1725+
to false by default on Windows.
1726+
1727+
Both `call` and `spawn` correspond in their behavior to their counterparts in the `os.proc`,
1728+
but `spawn` returns the `os.ProcessPipeline` instance instead. It offers the same
1729+
`API` as `SubProcess`, but will operate on the set of processes instead of a single one.
1730+
1731+
`Pipefail` is enabled by default, so if any of the processes in the pipeline fails, the whole
1732+
pipeline will have a non-zero exit code. This behavior can be disabled via the `pipefail` flag
1733+
on `call` and `spawn` methods. Note that the pipefail does not kill the processes in the pipeline,
1734+
it just sets the exit code of the pipeline to the exit code of the failed process.
1735+
16941736
=== Watching for Changes
16951737

16961738
==== `os.watch.watch`
@@ -1752,8 +1794,6 @@ paths changed: /Users/lihaoyi/Github/Ammonite/out/i am,/Users/lihaoyi/Github/Amm
17521794
paths changed: /Users/lihaoyi/Github/Ammonite/out/version/log,/Users/lihaoyi/Github/Ammonite/out/version/meta.json,/Users/lihaoyi/Github/Ammonite/out/version
17531795
----
17541796

1755-
`watch` currently only supports Linux and Mac-OSX, and not Windows.
1756-
17571797
== Data Types
17581798

17591799
=== `os.Path`
@@ -2059,6 +2099,38 @@ Python, ...) do. Even in cases where it's uncertain, e.g. you're taking user
20592099
input as a String, you have to either handle both possibilities with BasePath or
20602100
explicitly choose to convert relative paths to absolute using some base.
20612101

2102+
==== Roots and filesystems
2103+
2104+
If you are using a system that supports different roots of paths, e.g. Windows,
2105+
you can use the argument of `os.root` to specify which root you want to use.
2106+
If not specified, the default root will be used (usually, C on Windows, / on Unix).
2107+
2108+
[source,scala]
2109+
----
2110+
val root = os.root('C:\') / "Users" / "me"
2111+
assert(root == os.Path("C:\Users\me"))
2112+
----
2113+
2114+
Additionally, custom filesystems can be specified by passing a `FileSystem` to
2115+
`os.root`. This allows you to use OS-Lib with non-standard filesystems, such as
2116+
jar filesystems or in-memory filesystems.
2117+
2118+
[source,scala]
2119+
----
2120+
val uri = new URI("jar", Paths.get("foo.jar").toURI().toString, null);
2121+
val env = new HashMap[String, String]();
2122+
env.put("create", "true");
2123+
val fs = FileSystems.newFileSystem(uri, env);
2124+
val path = os.root("/", fs) / "dir"
2125+
----
2126+
2127+
Note that the jar file system operations suchs as writing to a file are supported
2128+
only on JVM 11+. Depending on the filesystem, some operations may not be supported -
2129+
for example, running an `os.proc` with pwd in a jar file won't work. You may also
2130+
meet limitations imposed by the implementations - in jar file system, the files are
2131+
created only after the file system is closed. Until that, the ones created in your
2132+
program are kept in memory.
2133+
20622134
==== `os.ResourcePath`
20632135

20642136
In addition to manipulating paths on the filesystem, you can also manipulate
@@ -2186,6 +2258,31 @@ string, int or set representations of the `os.PermSet` via:
21862258

21872259
== Changelog
21882260

2261+
[#0-10-0]
2262+
=== 0.10.0
2263+
2264+
* Support for Scala-Native 0.5.0
2265+
* Dropped support for Scala 2.11.x
2266+
* Minimum version of Scala 3 increased to 3.3.1
2267+
2268+
2269+
[#0-9-3]
2270+
=== 0.9.3 - 2024-01-01
2271+
2272+
* Fix `os.watch` on Windows (#236)
2273+
* Fix propagateEnv = false to not propagate env (#238)
2274+
* Make os.home a def (#239)
2275+
2276+
=== 0.9.2 - 2023-11-05
2277+
2278+
* Added new convenience API to create pipes between processes with `.pipeTo`
2279+
* Fixed issue with leading `..` / `os.up` in path segments created from a `Seq`
2280+
* Fixed Windows-specific issues with relative paths with leading (back)slashes
2281+
* Removed some internal use of deprecated API
2282+
* ScalaDoc now maps some external references to their online sites
2283+
* Dependency updates: sourcecode 0.3.1
2284+
* Tooling updates: acyclic 0.3.9, Mill 0.11.5, mill-mima 0.0.24, mill-vcs-version 0.4.0, scalafmt 3.7.15
2285+
21892286
=== 0.9.1 - 2023-03-07
21902287

21912288
* Refined return types when constructing paths with `/` and get rid of long `ThisType#ThisType` cascades.

0 commit comments

Comments
 (0)