From a0aed5cc2645182c4a08783e6a7561892ffa74c4 Mon Sep 17 00:00:00 2001 From: Michal Kleiner Date: Thu, 12 Feb 2015 18:19:59 +1300 Subject: [PATCH 1/2] Update parser.js Allows for any general cache buster param passed within options object, preferably a hash of content of the blessed file --- lib/bless/parser.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/bless/parser.js b/lib/bless/parser.js index a88b935..6c62f37 100644 --- a/lib/bless/parser.js +++ b/lib/bless/parser.js @@ -2,13 +2,15 @@ var path = require('path'), fs = require('fs'), + crypto = require('crypto'), bless = exports, - cacheBuster = '?z=' + new Date().getTime(); + cacheBusterTimestamp = new Date().getTime(); bless.Parser = function Parser(env) { this.env = env = env || {}; var output = this.env.output, - options = this.env.options; + options = this.env.options, + cacheBusterParam = options.cacheBusterParam ? ('?z=' + options.cacheBusterParam) : ('?z=' + cacheBusterTimestamp); // // The Parser @@ -93,9 +95,9 @@ bless.Parser = function Parser(env) { for(var k=1; k<=filesLength; k++) { var outputFilename = filename + '-blessed' + k + ext; if (options.cacheBuster) { - outputFilename += cacheBuster; + outputFilename += cacheBusterParam; } - var importStr = '@import url(\'' + outputFilename + '\');'; + var importStr = '@import url(\'' + outputFilename + '\'); /* */'; importStr = options.compress ? importStr : importStr + '\n'; rules.unshift(importStr); } @@ -119,10 +121,11 @@ bless.Parser.cleanup = function (options, output, callback) { dir = path.dirname(output), ext = path.extname(output), filename = path.basename(output, ext), - fileRegex = filename + '-blessed' + '(\\d+)' + ext; + fileRegex = filename + '-blessed' + '(\\d+)' + ext, + cacheBusterParam = options.cacheBusterParam ? ('?z=' + options.cacheBusterParam) : ('?z=' + cacheBusterTimestamp); if (options.cacheBuster) { - fileRegex += cacheBuster; + fileRegex += cacheBusterParam; } var importRegex = '@import url\\(\'(' + fileRegex + '\')\\);'; From 5ae8bd225c43b61aea7d96f095104bc12c57ac5b Mon Sep 17 00:00:00 2001 From: Michal Kleiner Date: Thu, 12 Feb 2015 18:21:08 +1300 Subject: [PATCH 2/2] Update parser.js Removed forgotten testing comment --- lib/bless/parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bless/parser.js b/lib/bless/parser.js index 6c62f37..a1f7c42 100644 --- a/lib/bless/parser.js +++ b/lib/bless/parser.js @@ -97,7 +97,7 @@ bless.Parser = function Parser(env) { if (options.cacheBuster) { outputFilename += cacheBusterParam; } - var importStr = '@import url(\'' + outputFilename + '\'); /* */'; + var importStr = '@import url(\'' + outputFilename + '\');'; importStr = options.compress ? importStr : importStr + '\n'; rules.unshift(importStr); }