Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

style consistency changes

  • Loading branch information...
commit cf9048ce7e4919ff14f0127459a06f9b6fbc56f7 1 parent aecef81
XhmikosR XhmikosR authored
27 bin/enhancecss
View
@@ -18,13 +18,20 @@ var options = {
};
var fromStdin = !process.env['__DIRECT__'] && process.stdin.readable;
-if (argv.noembedversion) options.noEmbed = true;
-if (argv.assethosts) options.assetHosts = argv.assethosts;
-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;
+if (argv.noembedversion)
+ options.noEmbed = true;
+if (argv.assethosts)
+ options.assetHosts = argv.assethosts;
+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();
@@ -41,7 +48,8 @@ if (argv.h || argv.help || (!fromStdin && argv._.length == 0)) {
if (options.source) {
fs.readFile(options.source, 'utf8', function(error, text) {
- if (error) throw error;
+ if (error)
+ throw error;
enhance(text, output);
});
} else {
@@ -60,7 +68,8 @@ function enhance(source, callback) {
pregzip: options.pregzip,
stamp: options.stamp
}).process(source, function(error, data) {
- if (error) throw error;
+ if (error)
+ throw error;
callback(data);
});
}
2  index.js
View
@@ -1 +1 @@
-module.exports = require("./lib/enhance");
+module.exports = require('./lib/enhance');
42 lib/enhance.js
View
@@ -62,11 +62,14 @@ EnhanceCSS.prototype = {
}
var type = path.extname(pathInfo.relative).substring(1);
- if (type == 'jpg') type = 'jpeg';
- if (type == 'svg') type = 'svg+xml';
+ if (type == 'jpg')
+ type = 'jpeg';
+ if (type == 'svg')
+ type = 'svg+xml';
// Break unless unsupported type
- if (!/(jpeg|gif|png|svg\+xml)/.test(type)) return match;
+ if (!/(jpeg|gif|png|svg\+xml)/.test(type))
+ return match;
var base64 = fs.readFileSync(pathInfo.absolute).toString('base64');
@@ -80,11 +83,11 @@ EnhanceCSS.prototype = {
var pathInfo = self.parseImageUrl(url);
// Break early if file does not exist
- if (!pathInfo.exists) return match;
+ if (!pathInfo.exists)
+ return match;
- if (self.options.stamp) {
+ if (self.options.stamp)
self._addFileStamp(pathInfo);
- }
return ['url(', (self.nextAssetHost() || ''), pathInfo.relative, ')'].join('');
});
@@ -101,7 +104,8 @@ EnhanceCSS.prototype = {
data.duplicates = [];
for (var key in embedUrls) {
if (hasOwnProperty.call(embedUrls, key)) {
- if (embedUrls[key] > 1) data.duplicates.push(key);
+ if (embedUrls[key] > 1)
+ data.duplicates.push(key);
}
}
@@ -111,18 +115,22 @@ EnhanceCSS.prototype = {
var compress = function(type) {
zlib.gzip(data[type].plain, function(error, result) {
data[type].compressed = result;
- if (--count == 0) callback(null, data);
+ if (--count == 0)
+ callback(null, data);
});
};
compress('embedded');
- if (this.options.noEmbedVersion) compress('notEmbedded');
+ if (this.options.noEmbedVersion)
+ compress('notEmbedded');
return;
}
- if (callback) callback(null, data);
- else return data;
+ if (callback)
+ callback(null, data);
+ else
+ return data;
},
parseImageUrl: function(url) {
@@ -144,8 +152,10 @@ EnhanceCSS.prototype = {
nextAssetHost: function() {
var hosts = this.options.assetHosts;
- if (!hosts) return null;
- if (hosts.indexOf('[') == -1) return this._fixAssetHost(hosts);
+ if (!hosts)
+ return null;
+ if (hosts.indexOf('[') == -1)
+ return this._fixAssetHost(hosts);
if (!this.hostsCycle) {
this.hostsCycle = {
@@ -164,7 +174,8 @@ EnhanceCSS.prototype = {
this.index = 0;
}
- if (this.index == this.cycleList.length) this.index = 0;
+ if (this.index == this.cycleList.length)
+ this.index = 0;
return this.cycleList[this.index++];
}
};
@@ -183,7 +194,8 @@ EnhanceCSS.prototype = {
},
_addFileStamp: function(pathInfo) {
- if (!existsSync(pathInfo.absolute)) return;
+ if (!existsSync(pathInfo.absolute))
+ return;
if (this.options.cryptedStamp && (pathInfo.query.embed === undefined || this.options.noEmbedVersion)) {
var source = fs.readFileSync(pathInfo.absolute),
5 test/binary-test.js
View
@@ -49,7 +49,8 @@ var cleanup = function(no, callback) {
fs.unlink('/tmp/test' + no + '.css.gz');
fs.unlink('/tmp/test' + no + '-noembed.css.gz');
- if (callback) callback();
+ if (callback)
+ callback();
};
var binaryContext = function(options, context) {
@@ -144,4 +145,4 @@ vows.describe('enhance css binary').addBatch({
exec('rm -rf ' + process.cwd() + '/test/data/gradient-*.png');
})
})
-}).export(module);
+}).export(module);
8 test/embed-test.js
View
@@ -10,7 +10,8 @@ var vows = require('vows'),
EnhanceCSS = require('../lib/enhance.js');
var runOn = function(css, extraOptions) {
- if (!extraOptions) extraOptions = {};
+ if (!extraOptions)
+ extraOptions = {};
return function() {
return new EnhanceCSS(append({ rootPath: process.cwd() }, extraOptions)).process(css, this.callback);
@@ -18,7 +19,8 @@ var runOn = function(css, extraOptions) {
};
var append = function(o1, o2) {
- for (var k in o2) o1[k] = o2[k];
+ for (var k in o2)
+ o1[k] = o2[k];
return o1;
};
@@ -569,4 +571,4 @@ vows.describe('embedding images').addBatch({
assert.equal(data.notEmbedded.plain, data.original);
}
}
-}).export(module);
+}).export(module);
Please sign in to comment.
Something went wrong with that request. Please try again.