Skip to content

Commit 036527c

Browse files
committed
edit changelog
1 parent aa4637e commit 036527c

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to `phpunit-watcher` will be documented in this file
44

5+
## 1.2.1 - 2017-08-05
6+
7+
- throw exception if config file does not contain yml
8+
59
## 1.2.0 - 2017-08-05
610

711
- check parent directories for config file
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Spatie\PhpUnitWatcher\Exceptions;
4+
5+
use Exception;
6+
7+
class InvalidConfigfile extends Exception
8+
{
9+
public static function invalidContents(string $path)
10+
{
11+
return new static("The content of configfile `{$path}` is not valid. Make sure this file contains valid yaml.");
12+
}
13+
}

src/WatcherCommand.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Spatie\PhpUnitWatcher;
44

5+
use Spatie\PhpUnitWatcher\Exceptions\InvalidConfigfile;
56
use Symfony\Component\Yaml\Yaml;
67
use Symfony\Component\Console\Command\Command;
78
use Symfony\Component\Console\Style\SymfonyStyle;
@@ -48,7 +49,13 @@ protected function getOptionsFromConfigFile(): array
4849
return [];
4950
}
5051

51-
return Yaml::parse(file_get_contents($configFile));
52+
$options = Yaml::parse(file_get_contents($configFile));
53+
54+
if (is_null($options)) {
55+
throw InvalidConfigfile::invalidContents($configFile);
56+
}
57+
58+
return $options;
5259
}
5360

5461
protected function getConfigFileLocation()

0 commit comments

Comments
 (0)