Skip to content

Commit 94f4ac6

Browse files
committed
minor fixes for setting config options
1 parent 949c513 commit 94f4ac6

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/PatternLab/Config.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public static function setOption($optionName = "", $optionValue = "") {
266266
}
267267

268268
$arrayFinder = new ArrayFinder(self::$options);
269-
$arrayFinder->set($key, $value);
269+
$arrayFinder->set($optionName, $optionValue);
270270
self::$options = $arrayFinder->get();
271271

272272
}
@@ -323,7 +323,8 @@ public static function updateConfigOption($optionName,$optionValue, $force = fal
323323
} else if (self::$options["overrideConfig"] == "q") {
324324

325325
// standardize the values for comparison
326-
$currentOptionValue = is_array(self::$options[$optionName]) ? implode(", ",self::$options[$optionName]) : self::$options[$optionName];
326+
$currentOption = self::getOption($optionName);
327+
$currentOptionValue = is_array($currentOption) ? implode(", ",$currentOption) : $currentOption;
327328
$newOptionValue = is_array($optionValue) ? implode(", ",$optionValue) : $optionValue;
328329

329330
if ($currentOptionValue != $newOptionValue) {
@@ -373,18 +374,11 @@ protected static function writeUpdateConfigOption($optionName,$optionValue) {
373374
Console::writeError("Config parse error in <path>".self::$userConfigPath."</path>: ".$e->getMessage());
374375
}
375376

376-
if (isset($options[$optionName]) && is_array($options[$optionName])) {
377-
$optionValue = is_array($optionValue) ? $optionValue : array($optionValue);
378-
$options[$optionName] = array_merge($options[$optionName], $optionValue);
379-
} else {
380-
$options[$optionName] = $optionValue;
381-
}
382-
383-
// reload the options
384-
self::$options = $options;
377+
print "foo ".$optionName." ".$optionValue;
378+
self::setOption($optionName, $optionValue);
385379

386380
// dump the YAML
387-
$configOutput = Yaml::dump($options, 3);
381+
$configOutput = Yaml::dump(self::$options, 3);
388382

389383
// write out the new config file
390384
file_put_contents(self::$userConfigPath,$configOutput);

src/PatternLab/Console/Commands/ConfigCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function run() {
7777
$updateOptionBits = explode("=",$updateOption);
7878
if (count($updateOptionBits) == 1) {
7979
Console::writeError("the --set value should look like <info>optionName=\"optionValue\"</info>. nothing was updated...");
80-
}
80+
}
8181

8282
// set the name and value that were passed
8383
$updateName = $updateOptionBits[0];
@@ -90,6 +90,7 @@ public function run() {
9090
Console::writeError("the --set option you provided, <info>".$updateName."</info>, does not exists in the config. nothing will be updated...");
9191
} else {
9292
Config::updateConfigOption($updateName,$updateValue);
93+
Console::writeInfo("config option updated...");
9394
}
9495

9596
} else {

0 commit comments

Comments
 (0)