Skip to content

Commit 2b8a581

Browse files
committed
smarter handling of missing dirs and dir options
1 parent a5a6bb2 commit 2b8a581

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/PatternLab/Config.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,18 @@ public static function init($baseDir = "", $verbose = true) {
219219
}
220220

221221
// double-check a few directories are real
222-
if (!is_dir(self::$options["sourceDir"])) {
222+
// refactor this at some point. it's verbose
223+
if (!isset(self::$options["sourceDir"])) {
224+
Console::writeError("please make sure sourceDir is set in <path>./config/config.yml</path> by adding 'sourceDir=some/path'. sorry, stopping pattern lab... :(");
225+
} else if (!is_dir(self::$options["sourceDir"])) {
223226
Console::writeError("hrm... i can't seem to find the directory with your source files. are you sure they're at <path>".Console::getHumanReadablePath(self::$options["sourceDir"])."</path>? you can fix this in <path>./config/config.yml</path> by editing sourceDir. sorry, stopping pattern lab... :(");
224227
}
225-
if (!is_dir(self::$options["publicDir"])) {
228+
if (!isset(self::$options["publicDir"])) {
229+
Console::writeError("please make sure publicDir is set in <path>./config/config.yml</path> by adding 'publicDir=some/path'. sorry, stopping pattern lab... :(");
230+
} else if (!is_dir(self::$options["publicDir"])) {
226231
Console::writeError("hrm... i can't seem to find the directory where you want to write your styleguide. are you sure it's at <path>".Console::getHumanReadablePath(self::$options["sourceDir"])."</path>? you can fix this in <path>./config/config.yml</path> by editing publicDir. sorry, stopping pattern lab... :(");
227232
}
228-
if (!is_dir(self::$options["styleguideKitPath"])) {
233+
if (isset(self::$options["styleguideKitPath"]) && !is_dir(self::$options["styleguideKitPath"])) {
229234
Console::writeError("hrm... i can't seem to find the directory where your styleguide files are located. are you sure it's at <path>".Console::getHumanReadablePath(self::$options["styleguideKitPath"])."</path>? you can fix this in <path>./config/config.yml</path> by editing styleguideKitPath. sorry, stopping pattern lab... :(");
230235
}
231236

0 commit comments

Comments
 (0)