@@ -203,13 +203,19 @@ object SjsonnetMainBase {
203203
204204 def splitMap (s : Seq [String ], f : String => String ) =
205205 s.map(split).map { case (x, v) => (x, f(v)) }
206- def readPath (v : String ) = os.read(os.Path (v, wd))
206+ def readPath (v : String ) =
207+ if (v == " -" || v == " /dev/stdin" ) io.Source .stdin.mkString else os.read(os.Path (v, wd))
207208
208209 Map () ++
209210 splitMap(strs, v => ujson.write(v)) ++
210211 splitMap(strFiles, v => ujson.write(readPath(v))) ++
211212 splitMap(codes, identity) ++
212- splitMap(codeFiles, v => s " import @' ${v.replace(" '" , " ''" )}' " )
213+ splitMap(
214+ codeFiles,
215+ v =>
216+ if (v == " -" || v == " /dev/stdin" ) io.Source .stdin.mkString
217+ else s " import @' ${v.replace(" '" , " ''" )}' "
218+ )
213219 }
214220
215221 /**
@@ -229,6 +235,10 @@ object SjsonnetMainBase {
229235
230236 val (jsonnetCode, path) =
231237 if (config.exec.value) (file, wd / Util .wrapInLessThanGreaterThan(" exec" ))
238+ // TODO: Get rid of the /dev/stdin special-casing (everywhere!) once we use scala-native
239+ // with https://github.com/scala-native/scala-native/issues/4384 fixed.
240+ else if (file == " -" || file == " /dev/stdin" )
241+ (io.Source .stdin.mkString, wd / Util .wrapInLessThanGreaterThan(" <stdin>" ))
232242 else {
233243 val p = os.Path (file, wd)
234244 (os.read(p), p)
0 commit comments