Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit b62b40a

Browse files
committed
can use the flag -n to turn off cacheBuster
1 parent 6aadb16 commit b62b40a

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

core/builder.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
}
5757

5858
// grab the arguments from the command line
59-
$args = getopt("gwcrvp");
59+
$args = getopt("gwcrvpn");
6060

6161
// load Pattern Lab's config, if first time set-up move files appropriately too
6262
$co = new PatternLab\Configurer;
@@ -74,8 +74,9 @@
7474
$g = new PatternLab\Generator($config);
7575

7676
// set some default values
77-
$enableCSS = false;
78-
$moveStatic = true;
77+
$enableCSS = false;
78+
$moveStatic = true;
79+
$noCacheBuster = false;
7980

8081
// check to see if CSS for patterns should be parsed & outputted
8182
if (isset($args["c"]) && !isset($args["w"])) {
@@ -87,7 +88,12 @@
8788
$moveStatic = false;
8889
}
8990

90-
$g->generate($enableCSS,$moveStatic);
91+
// check to see if we should turn off the cachebuster value
92+
if (isset($args["n"])) {
93+
$noCacheBuster = true;
94+
}
95+
96+
$g->generate($enableCSS,$moveStatic,$noCacheBuster);
9197

9298
// have some fun
9399
if (!isset($args["w"])) {

core/lib/PatternLab/Builder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class Builder {
4444
protected $patternCSS; // an array to hold the CSS generated for patterns
4545
protected $cssRuleSaver; // where css rule saver will be initialized
4646
protected $cacheBuster; // a timestamp used to bust the cache for static assets like CSS and JS
47+
protected $noCacheBuster; // should we turn the cache buster on or off?
4748
protected $patternHead; // the header to be included on patterns
4849
protected $patternFoot; // the footer to be included on patterns
4950
protected $mainPageHead; // the header to be included on main pages
@@ -390,7 +391,7 @@ protected function generateViewAllPages() {
390391
protected function gatherData() {
391392

392393
// set the cacheBuster
393-
$this->cacheBuster = time();
394+
$this->cacheBuster = $this->noCacheBuster ? 0 : time();
394395

395396
// gather the data from the main source data.json
396397
if (file_exists($this->sd."/_data/_data.json")) {

core/lib/PatternLab/Generator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct($config = array()) {
3030
* @param {Boolean} decide if CSS should be parsed and saved. performance hog.
3131
* @param {Boolean} decide if static files like CSS and JS should be moved
3232
*/
33-
public function generate($enableCSS = false, $moveStatic = true) {
33+
public function generate($enableCSS = false, $moveStatic = true, $noCacheBuster = false) {
3434

3535
$timePL = true; // track how long it takes to generate a PL site
3636

@@ -41,6 +41,8 @@ public function generate($enableCSS = false, $moveStatic = true) {
4141
$starttime = $mtime;
4242
}
4343

44+
$this->noCacheBuster = $noCacheBuster;
45+
4446
if ($enableCSS) {
4547

4648
// enable CSS globally throughout PL

0 commit comments

Comments
 (0)