Skip to content

Commit 1201ba2

Browse files
committed
mill watch console
1 parent bbafbf1 commit 1201ba2

File tree

2 files changed

+49
-29
lines changed

2 files changed

+49
-29
lines changed

justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ serveMill:
3838
setupPlaywright:
3939
cs launch com.microsoft.playwright:playwright:1.41.1 -M "com.microsoft.playwright.CLI" -- install --with-deps
4040

41-
publish:
42-
mill
41+
publishLocal:
42+
mill project.publishLocal
4343

4444
setupMill:
4545
curl -L https://raw.githubusercontent.com/lefou/millw/0.4.11/millw > mill && chmod +x mill

project/src/build.runner.scala

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -122,30 +122,30 @@ def buildRunnerMill(
122122
)(
123123
logger: Scribe[IO]
124124
): ResourceIO[Unit] =
125-
val watchLinkComplePath = workDir / "out" / moduleName / "fastLinkJS.json"
126-
127-
val watcher = fs2
128-
.Stream
129-
.resource(Watcher.default[IO].evalTap(_.watch(watchLinkComplePath.toNioPath)))
130-
.flatMap {
131-
_.events(100.millis)
132-
.evalTap {
133-
(e: Event) =>
134-
e match
135-
case Created(path, count) => logger.info("fastLinkJs.json was created")
136-
case Deleted(path, count) => logger.info("fastLinkJs.json was deleted")
137-
case Modified(path, count) =>
138-
logger.info("fastLinkJs.json was modified - link successful => trigger a refresh") >>
139-
linkingTopic.publish1(())
140-
case Overflow(count) => logger.info("overflow")
141-
case NonStandard(event, registeredDirectory) => logger.info("non-standard")
125+
// val watchLinkComplePath = workDir / "out" / moduleName / "fastLinkJS.json"
142126

143-
}
144-
}
145-
.compile
146-
.drain
147-
.background
148-
.void
127+
// val watcher = fs2
128+
// .Stream
129+
// .resource(Watcher.default[IO].evalTap(_.watch(watchLinkComplePath.toNioPath)))
130+
// .flatMap {
131+
// _.events(100.millis)
132+
// .evalTap {
133+
// (e: Event) =>
134+
// e match
135+
// case Created(path, count) => logger.info("fastLinkJs.json was created")
136+
// case Deleted(path, count) => logger.info("fastLinkJs.json was deleted")
137+
// case Modified(path, count) =>
138+
// logger.info("fastLinkJs.json was modified - link successful => trigger a refresh") >>
139+
// linkingTopic.publish1(())
140+
// case Overflow(count) => logger.info("overflow")
141+
// case NonStandard(event, registeredDirectory) => logger.info("non-standard")
142+
143+
// }
144+
// }
145+
// .compile
146+
// .drain
147+
// .background
148+
// .void
149149

150150
val millargs = List(
151151
"-w",
@@ -162,17 +162,37 @@ def buildRunnerMill(
162162
.use {
163163
p =>
164164
// p.stderr.through(fs2.io.stdout).compile.drain >>
165-
p.stdout.through(text.utf8.decode).debug().compile.drain
165+
// val stdOut = p.stdout.through(text.utf8.decode).debug().compile.drain
166+
// val stdErr = p.stderr.through(text.utf8.decode).debug().compile.drain
167+
// stdOut.both(stdErr).void
168+
169+
p.stderr
170+
.through(text.utf8.decode)
171+
.debug()
172+
.chunks
173+
.evalMap(
174+
aChunk =>
175+
if aChunk.head.exists(_.startsWith("Emitter")) then
176+
logger.trace("Detected that linking was successful, emitting refresh event") >>
177+
linkingTopic.publish1(())
178+
else
179+
logger.trace(s"$aChunk :: Linking unfinished") >>
180+
IO.unit
181+
end if
182+
)
183+
.compile
184+
.drain
185+
// .both(stdOut)
186+
// .both(stdErr).void
166187
}
167188
.background
168189
.void
169190

170191
for
171192
_ <- logger.trace("Starting buildRunnerMill").toResource
172-
_ <- logger.trace(s"watching path $watchLinkComplePath").toResource
173-
_ <- logger.trace(s"running mill with args $millargs").toResource
193+
_ <- logger.debug(s"running $invokeVia with args $millargs").toResource
174194
_ <- builder
175-
_ <- watcher
195+
// _ <- watcher
176196
yield ()
177197
end for
178198

0 commit comments

Comments
 (0)