@@ -203,13 +203,19 @@ object SjsonnetMainBase {
203
203
204
204
def splitMap (s : Seq [String ], f : String => String ) =
205
205
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))
207
208
208
209
Map () ++
209
210
splitMap(strs, v => ujson.write(v)) ++
210
211
splitMap(strFiles, v => ujson.write(readPath(v))) ++
211
212
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
+ )
213
219
}
214
220
215
221
/**
@@ -229,6 +235,10 @@ object SjsonnetMainBase {
229
235
230
236
val (jsonnetCode, path) =
231
237
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>" ))
232
242
else {
233
243
val p = os.Path (file, wd)
234
244
(os.read(p), p)
0 commit comments