Skip to content

Commit

Permalink
try creating report folder if not exists (#4353)
Browse files Browse the repository at this point in the history
Co-authored-by: Pascal Heidmann <heidmann@kigaroo.de>
  • Loading branch information
2 people authored and muglug committed Oct 19, 2020
1 parent 2f75e25 commit fbd9161
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Psalm/IssueBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
use function array_splice;
use function count;
use function debug_print_backtrace;
use function dirname;
use function explode;
use function file_put_contents;
use function fwrite;
use function get_class;
use function is_dir;
use function memory_get_peak_usage;
use function mkdir;
use function microtime;
use function number_format;
use function ob_get_clean;
use function ob_start;
use function sprintf;
use Psalm\Internal\Analyzer\IssueData;
use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Issue\CodeIssue;
Expand Down Expand Up @@ -561,6 +565,10 @@ function (IssueData $d1, IssueData $d2) : int {
throw new \UnexpectedValueException('Output path should not be null here');
}

$folder = dirname($report_options->output_path);
if (!is_dir($folder) && !mkdir($folder, 0777, true) && !is_dir($folder)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $folder));
}
file_put_contents(
$report_options->output_path,
self::getOutput(
Expand Down

0 comments on commit fbd9161

Please sign in to comment.