@@ -347,11 +347,7 @@ defmodule Asciinema.Streaming.StreamServer do
347
347
file = File . open! ( path , [ :write , :utf8 ] )
348
348
state = % { state | path: path , file: file }
349
349
timestamp = Timex . to_unix ( Timex . now ( ) )
350
-
351
- env =
352
- % { "TERM" => query [ "term" ] , "SHELL" => query [ "shell" ] }
353
- |> Enum . filter ( fn { _k , v } -> v != nil and v != "" end )
354
- |> Enum . into ( % { } )
350
+ env = drop_empty ( query [ "env" ] || % { } )
355
351
356
352
write_asciicast_v2_header ( file , cols , rows , timestamp , env , theme )
357
353
@@ -364,16 +360,14 @@ defmodule Asciinema.Streaming.StreamServer do
364
360
365
361
defp write_asciicast_v2_header ( file , cols , rows , timestamp , env , theme ) do
366
362
header =
367
- % {
363
+ drop_empty ( % {
368
364
version: 2 ,
369
365
width: cols ,
370
366
height: rows ,
371
367
timestamp: timestamp ,
372
368
env: env ,
373
369
theme: asciicast_theme ( theme )
374
- }
375
- |> Enum . filter ( fn { _k , v } -> v != nil and v != % { } end )
376
- |> Enum . into ( % { } )
370
+ } )
377
371
378
372
:ok = IO . write ( file , Jason . encode! ( header ) <> "\n " )
379
373
end
@@ -387,6 +381,12 @@ defmodule Asciinema.Streaming.StreamServer do
387
381
:ok = IO . write ( file , event <> "\n " )
388
382
end
389
383
384
+ defp drop_empty ( map ) when is_map ( map ) do
385
+ map
386
+ |> Enum . filter ( fn { _k , v } -> v != nil and v != "" and v != % { } end )
387
+ |> Enum . into ( % { } )
388
+ end
389
+
390
390
defp in_sync? ( state , last_event_id ) ,
391
391
do: last_event_id != 0 and last_event_id == state . last_event_id
392
392
0 commit comments