diff options
author | Jasper Maes <jaspermaes.jm@gmail.com> | 2018-08-26 20:41:18 +0300 |
---|---|---|
committer | Jasper Maes <jaspermaes.jm@gmail.com> | 2018-08-28 14:47:40 +0300 |
commit | 86a8955cf35b34b5a866d69f0766877e4e26e0f7 (patch) | |
tree | 496228c1f282fa1abbc707f5d1487e59b51bae31 | |
parent | 68b84d8154a92876fb2c308b2ca16eb78f2b3933 (diff) |
Rails 5: replace removed silence_stream
-rw-r--r-- | changelogs/unreleased/rails5-silence-stream.yml | 5 | ||||
-rw-r--r-- | lib/tasks/gettext.rake | 13 |
2 files changed, 17 insertions, 1 deletions
diff --git a/changelogs/unreleased/rails5-silence-stream.yml b/changelogs/unreleased/rails5-silence-stream.yml new file mode 100644 index 00000000000..df4fd14a077 --- /dev/null +++ b/changelogs/unreleased/rails5-silence-stream.yml @@ -0,0 +1,5 @@ +--- +title: 'Rails 5: replace removed silence_stream' +merge_request: 21387 +author: Jasper Maes +type: other diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake index f431352b61e..a497d26312e 100644 --- a/lib/tasks/gettext.rake +++ b/lib/tasks/gettext.rake @@ -82,7 +82,7 @@ namespace :gettext do # `gettext:find` writes touches to temp files to `stderr` which would cause # `static-analysis` to report failures. We can ignore these. - silence_stream($stderr) do + silence_sdterr do Rake::Task['gettext:find'].invoke end @@ -118,4 +118,15 @@ namespace :gettext do end end end + + def silence_sdterr(&block) + old_stderr = $stderr.dup + $stderr.reopen(File::NULL) + $stderr.sync = true + + yield + ensure + $stderr.reopen(old_stderr) + old_stderr.close + end end |