Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added '--nostamp' option to binary.

  • Loading branch information...
commit 09772f3b444b567c6ed16a2d22393615013aa2cb 1 parent e919372
@GoalSmashers GoalSmashers authored
View
7 bin/enhancecss
@@ -13,7 +13,8 @@ var options = {
assetHosts: null,
pregzip: false,
noEmbed: false,
- cryptedStamp: false
+ cryptedStamp: false,
+ stamp: true
};
var fromStdin = !process.env['__DIRECT__'] && process.stdin.readable;
@@ -23,6 +24,7 @@ if (argv.pregzip) options.pregzip = true;
if (argv.cryptedstamp) options.cryptedStamp = true;
if (argv.o) options.target = argv.o;
if (argv._) options.source = argv._[0];
+if (argv.nostamp) options.stamp = false;
options.rootPath = argv.root || process.cwd();
@@ -55,7 +57,8 @@ function enhance(source, callback) {
assetHosts: options.assetHosts,
noEmbedVersion: options.noEmbed,
cryptedStamp: options.cryptedStamp,
- pregzip: options.pregzip
+ pregzip: options.pregzip,
+ stamp: options.stamp
}).process(source, function(error, data) {
if (error) throw error;
callback(data);
View
9 lib/enhance.js
@@ -9,10 +9,7 @@ var isWindows = process.platform == 'win32';
var EnhanceCSS = function(options) {
this.options = options;
-
- if (typeof(options.stamp) === 'undefined') {
- this.options.stamp = true;
- }
+ this.options.stamp = ('stamp' in options) ? options.stamp : true;
};
EnhanceCSS.prototype = {
@@ -77,11 +74,11 @@ EnhanceCSS.prototype = {
// Break early if file does not exist
if (!pathInfo.exists) return match;
-
+
if (self.options.stamp) {
self._addFileStamp(pathInfo);
}
-
+
return ['url(', (self.nextAssetHost() || ''), pathInfo.relative, ')'].join('');
});
}
View
16 test/binary-test.js
@@ -22,9 +22,14 @@ var checkFiles = function(fileName, options) {
// verify content
assert.include(fs.readFileSync(pathToFile()).toString('utf8'), 'a{background:url(data:image/png;base64');
- if (options.noEmbed)
+ if (options.noEmbed) {
assert.include(fs.readFileSync(pathToFile(true)).toString('utf8'), 'a{background:url(/test/data/gradient');
+ if (options.stamp === false) {
+ assert.match(fs.readFileSync(pathToFile(true)).toString('utf8'), /gradient\.\w+\)/);
+ }
+ }
+
if (options.pregzip) {
zlib.gunzip(fs.readFileSync(pathToFile(false, true)), function(error, result) {
assert.include(result.toString('utf8'), 'a{background:url(data:image/png;base64');
@@ -93,6 +98,15 @@ vows.describe('enhance css binary').addBatch({
},
teardown: cleanup(1)
}),
+ 'simple embed with no stamps': pipelinedContext("--noembedversion --nostamp -o /tmp/test1.css", {
+ 'should give empty output': function(error, stdout) {
+ assert.isEmpty(stdout);
+ },
+ 'should create valid files': function() {
+ checkFiles('test1', { stamp: false, noEmbed: true, pregzip: false });
+ },
+ teardown: cleanup(1)
+ }),
'embed with --noembedversion option': pipelinedContext("--noembedversion -o /tmp/test2.css", {
'should give empty output': function(error, stdout) {
assert.isEmpty(stdout);
View
2  test/embed-test.js
@@ -561,7 +561,7 @@ vows.describe('embedding images').addBatch({
}
}).addBatch({
'not embedded files should not get mtime timestamp if "stamp" option equals false': {
- topic: runOn('div{background:url(/test/data/gradient.jpg)}', {stamp: false, noEmbedVersion: true}),
+ topic: runOn('div{background:url(/test/data/gradient.jpg)}', { stamp: false, noEmbedVersion: true }),
'in the "embedded" version': function(data) {
assert.equal(data.embedded.plain, data.original);
},
Please sign in to comment.
Something went wrong with that request. Please try again.