Commit da34e008c3b67b4d06ecc8a06a102271157f3c13
Exists in
spb-stable
and in
3 other branches
Merge pull request #5294 from dalehamel/master
Ensure directory exists before changing in popen
Showing
1 changed file
with
6 additions
and
0 deletions
Show diff stats
lib/gitlab/popen.rb
| 1 | +require 'fileutils' | |
| 2 | + | |
| 1 | 3 | module Gitlab |
| 2 | 4 | module Popen |
| 3 | 5 | def popen(cmd, path) |
| 4 | 6 | vars = { "PWD" => path } |
| 5 | 7 | options = { chdir: path } |
| 6 | 8 | |
| 9 | + unless File.directory?(path) | |
| 10 | + FileUtils.mkdir_p(path) | |
| 11 | + end | |
| 12 | + | |
| 7 | 13 | @cmd_output = "" |
| 8 | 14 | @cmd_status = 0 |
| 9 | 15 | Open3.popen3(vars, cmd, options) do |stdin, stdout, stderr, wait_thr| | ... | ... |