Skip to content

Commit b0be3a2

Browse files
committed
getting rid of refs to packagesDir in favor of configDir
1 parent 7fe8af2 commit b0be3a2

File tree

6 files changed

+19
-30
lines changed

6 files changed

+19
-30
lines changed

config/config.yml.default

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,5 @@ cacheBusterOn: "true"
3535

3636
# project directories
3737
exportDir: "export"
38-
packagesDir: "packages"
3938
publicDir: "public"
4039
sourceDir: "source"

src/PatternLab/Config.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected static function cleanDir($dir) {
4848
/**
4949
* Get the value associated with an option from the Config
5050
* @param {String} the name of the option to be checked
51-
*
51+
*
5252
* @return {String/Boolean} the value of the get or false if it wasn't found
5353
*/
5454
public static function getOption($optionName = "") {
@@ -67,7 +67,7 @@ public static function getOption($optionName = "") {
6767

6868
/**
6969
* Get the options set in the config
70-
*
70+
*
7171
* @return {Array} the options from the config
7272
*/
7373
public static function getOptions() {
@@ -180,7 +180,6 @@ public static function init($baseDir = "", $verbose = true) {
180180
// set-up the various dirs
181181
self::$options["coreDir"] = is_dir(self::$options["baseDir"]."_core") ? self::$options["baseDir"]."_core" : self::$options["baseDir"]."core";
182182
self::$options["exportDir"] = isset(self::$options["exportDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["exportDir"]) : self::$options["baseDir"]."exports";
183-
self::$options["packagesDir"] = isset(self::$options["packagesDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["packagesDir"]) : self::$options["baseDir"]."packages";
184183
self::$options["publicDir"] = isset(self::$options["publicDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["publicDir"]) : self::$options["baseDir"]."public";
185184
self::$options["scriptsDir"] = isset(self::$options["scriptsDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["scriptsDir"]) : self::$options["baseDir"]."scripts";
186185
self::$options["sourceDir"] = isset(self::$options["sourceDir"]) ? self::$options["baseDir"].self::cleanDir(self::$options["sourceDir"]) : self::$options["baseDir"]."source";
@@ -214,7 +213,7 @@ public static function init($baseDir = "", $verbose = true) {
214213
/**
215214
* Check to see if the given array is an associative array
216215
* @param {Array} the array to be checked
217-
*
216+
*
218217
* @return {Boolean} whether it's an associative array
219218
*/
220219
protected static function isAssoc($array) {
@@ -248,7 +247,7 @@ public static function loadOptions($data,$parentKey = "") {
248247
* Add an option and associated value to the base Config
249248
* @param {String} the name of the option to be added
250249
* @param {String} the value of the option to be added
251-
*
250+
*
252251
* @return {Boolean} whether the set was successful
253252
*/
254253
public static function setOption($optionName = "", $optionValue = "") {
@@ -269,7 +268,7 @@ public static function setOption($optionName = "", $optionValue = "") {
269268
/**
270269
* Add an option to the exposedOptions array so it can be exposed on the front-end
271270
* @param {String} the name of the option to be added to the exposedOption arrays
272-
*
271+
*
273272
* @return {Boolean} whether the set was successful
274273
*/
275274
public static function setExposedOption($optionName = "") {
@@ -337,7 +336,7 @@ public static function updateConfigOption($optionName,$optionValue) {
337336
* Update an option and associated value to the base Config
338337
* @param {String} the name of the option to be updated
339338
* @param {String} the value of the option to be updated
340-
*
339+
*
341340
* @return {Boolean} whether the update was successful
342341
*/
343342
public static function updateOption($optionName = "", $optionValue = "") {

src/PatternLab/Dispatcher.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,13 @@ public static function init() {
4646
protected static function loadListeners() {
4747

4848
// default var
49-
$packagesDir = Config::getOption("packagesDir");
50-
51-
// see if the package dir exists. if it doesn't make it
52-
if (!is_dir($packagesDir)) {
53-
mkdir($packagesDir);
54-
}
49+
$configDir = Config::getOption("configDir");
5550

5651
// make sure the listener data exists
57-
if (file_exists($packagesDir."/listeners.json")) {
52+
if (file_exists($configDir."/listeners.json")) {
5853

5954
// get listener list data
60-
$listenerList = json_decode(file_get_contents($packagesDir."/listeners.json"), true);
55+
$listenerList = json_decode(file_get_contents($configDir."/listeners.json"), true);
6156

6257
// get the listener info
6358
foreach ($listenerList["listeners"] as $listenerName) {

src/PatternLab/InstallerUtil.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ protected static function runTasks($installerInfo) {
646646
self::scanForPatternEngineRule($pathBase);
647647
} else if ($type == "patternlab-starterkit") {
648648
Config::updateConfigOption("starterKit",$name);
649+
Config::updateConfigOption("starterKitPath",$pathBase);
649650
} else if (($type == "patternlab-styleguidekit") && (strpos($name,"-assets-") === false)) {
650651
Config::updateConfigOption("styleguideKit",$name);
651652
}

src/PatternLab/PatternEngine.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,13 @@ public static function init() {
5757
public static function loadRules() {
5858

5959
// default var
60-
$packagesDir = Config::getOption("packagesDir");
61-
62-
// see if the package dir exists. if it doesn't it means composer hasn't been run
63-
if (!is_dir($packagesDir)) {
64-
Console::writeError("you haven't fully set-up Pattern Lab yet. please add a pattern engine...");
65-
}
60+
$configDir = Config::getOption("configDir");
6661

6762
// make sure the pattern engine data exists
68-
if (file_exists($packagesDir."/patternengines.json")) {
63+
if (file_exists($configDir."/patternengines.json")) {
6964

7065
// get pattern engine list data
71-
$patternEngineList = json_decode(file_get_contents($packagesDir."/patternengines.json"), true);
66+
$patternEngineList = json_decode(file_get_contents($configDir."/patternengines.json"), true);
7267

7368
// get the pattern engine info
7469
foreach ($patternEngineList["patternengines"] as $patternEngineName) {
@@ -78,7 +73,7 @@ public static function loadRules() {
7873
}
7974

8075
} else {
81-
Console::writeError("The pattern engines list isn't available in <path>".$packagesDir."</path>...");
76+
Console::writeError("The pattern engines list isn't available in <path>".$configDir."</path>...");
8277
}
8378

8479
}

src/PatternLab/Template.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2014 Dave Olsen, http://dmolsen.com
77
* Licensed under the MIT license
88
*
9-
* Set-ups the vars needed related to setting up and rendering templates. Meaning putting
9+
* Set-ups the vars needed related to setting up and rendering templates. Meaning putting
1010
*
1111
*/
1212

@@ -42,12 +42,12 @@ public static function init() {
4242

4343
// set-up config vars
4444
$patternExtension = Config::getOption("patternExtension");
45-
$pluginDir = Config::getOption("packagesDir");
4645
$sourceDir = Config::getOption("sourceDir");
4746
$styleguideKit = Config::getOption("styleguideKit");
47+
$styleguideKitPath = Config::getOption("styleguideKitPath");
4848

4949
// load pattern-lab's resources
50-
$partialPath = $pluginDir."/".$styleguideKit."/views/partials";
50+
$partialPath = $styleguideKitPath."/views/partials";
5151
self::$htmlHead = file_get_contents($partialPath."/general-header.".$patternExtension);
5252
self::$htmlFoot = file_get_contents($partialPath."/general-footer.".$patternExtension);
5353

@@ -62,8 +62,8 @@ public static function init() {
6262
$filesystemLoaderClass = $patternEngineBasePath."\Loaders\FilesystemLoader";
6363

6464
$options = array();
65-
$options["templatePath"] = $pluginDir."/".$styleguideKit."/views";
66-
$options["partialsPath"] = $pluginDir."/".$styleguideKit."/views/partials";
65+
$options["templatePath"] = $styleguideKitPath."/views";
66+
$options["partialsPath"] = $styleguideKitPath."/views/partials";
6767

6868
self::$filesystemLoader = new $filesystemLoaderClass($options);
6969

0 commit comments

Comments
 (0)