Skip to content

Commit

Permalink
Fix: codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
lexich committed Jan 18, 2016
1 parent 8b7029c commit d70df35
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 116 deletions.
40 changes: 0 additions & 40 deletions .jscsrc

This file was deleted.

4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ var gulp = require("gulp");
var istanbul = require("gulp-istanbul");
var mocha = require("gulp-mocha");

gulp.task("test", function(cb) {
gulp.task("test", function (cb) {
gulp.src(["test/main.js"])
.pipe(istanbul()) // Covering files
.pipe(istanbul.hookRequire()) // Force `require` to return covered files
.on("finish", function() {
.on("finish", function () {
gulp.src(["test/main.js"])
.pipe(mocha())
.pipe(istanbul.writeReports()) // Creating the reports after tests runned
Expand Down
21 changes: 11 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use strict";
/* eslint object-shorthand: 0 */
var nodecss = require("node-css"),
_ = require("lodash"),
libpath = require("path");
Expand All @@ -12,7 +13,7 @@ var css = new CSS();
function CSSImage() {
}

CSSImage.prototype.css = function(filepath, width, height, root, options) {
CSSImage.prototype.css = function (filepath, width, height, root, options) {
var classname = "." + this.name(filepath, options);
if (!options) { options = {}; }
if (options.retina) {
Expand All @@ -29,7 +30,7 @@ CSSImage.prototype.css = function(filepath, width, height, root, options) {
}, options);
};

CSSImage.prototype.scssVars = function(filepath, _width, _height, options) {
CSSImage.prototype.scssVars = function (filepath, _width, _height, options) {
var name = this.name(filepath, options);
var squeeze = (options && !!options.squeeze) ? +options.squeeze : 1;
var width = Math.floor(_width / squeeze);
Expand All @@ -42,7 +43,7 @@ CSSImage.prototype.scssVars = function(filepath, _width, _height, options) {
"$" + name + "__path: '" + this.normalizePath(filepath, root, retina) + "';\n";
};

CSSImage.prototype.scssMixin = function(filepath, _width, _height, root, options) {
CSSImage.prototype.scssMixin = function (filepath, _width, _height, root, options) {
var name = this.name(filepath, options);
if (!options) { options = {}; }
var classname = "@mixin " + name + "()";
Expand All @@ -57,30 +58,30 @@ CSSImage.prototype.scssMixin = function(filepath, _width, _height, root, options
height: height + "px",
"background-image": this.url(filepath, root),
"background-size": "" + width + "px " + height + "px"
}, {indent: indent});
}, { indent: indent });

if (isRetina) {
var body = css.body({
width: width + "px",
height: height + "px",
"background-image": this.url(filepath, root, options.retina),
"background-size": "" + width + "px " + height + "px"
}, {indent: indent + indent});
}, { indent: indent + indent });
scssMixin += indent + "@media " + MEDIA_QUERY + " {\n" + body + indent + "}\n";
}
return classname + " {\n" + scssMixin + "}\n";
};

CSSImage.prototype.scss = function(filepath, width, height, root, options) {
CSSImage.prototype.scss = function (filepath, width, height, root, options) {
return this.scssMixin(filepath, width, height, root, options) +
this.scssVars(filepath, width, height, options);
};

CSSImage.prototype.url = function(filepath, root, retina) {
CSSImage.prototype.url = function (filepath, root, retina) {
return "url(" + this.normalizePath(filepath, root, retina) + ")";
};

CSSImage.prototype.normalizePath = function(filepath, root, retina) {
CSSImage.prototype.normalizePath = function (filepath, root, retina) {
var name = libpath.basename(filepath);
var ext = libpath.extname(filepath);
if (!!retina) {
Expand All @@ -92,15 +93,15 @@ CSSImage.prototype.normalizePath = function(filepath, root, retina) {
return normalizedPath;
};

CSSImage.prototype.normalizeFolder = function(filepath, root) {
CSSImage.prototype.normalizeFolder = function (filepath, root) {
var folder = libpath.dirname(filepath);
if (folder[0] === "." && folder[1] !== ".") { folder = folder.slice(1); }
if (folder[0] === "/") { folder = folder.slice(1); }
var result = root ? libpath.join(root, folder) : folder;
return result.replace(rxReplacePath, "/").replace(rxCleanSpace, "");
};

CSSImage.prototype.name = function(filepath, options) {
CSSImage.prototype.name = function (filepath, options) {
var postfix = options && options.postfix ? options.postfix : "";
if (options && options.squeeze) { postfix += "-s" + options.squeeze; }
var prefix = options && (typeof options.prefix !== "undefined") ? options.prefix : "img_";
Expand Down
32 changes: 15 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
"main": "index.js",
"repository": "http://github.com/lexich/css-image",
"scripts": {
"test": "npm run eslint && npm run jscs && npm run mocha",
"test": "npm run eslint && npm run mocha",
"mocha": "istanbul test _mocha --report html -- test/*.js --reporter spec",
"coveralls": "npm run eslint && npm run jscs && istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"coveralls": "npm run eslint && istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"testgulp": "node_modules/.bin/gulp test",
"jscs": "node_modules/.bin/jscs ./*.js test/*.js",
"eslint": "node_modules/.bin/eslint ./*.js test/*.js"
},
"keywords": [
Expand All @@ -23,22 +22,21 @@
},
"license": "MIT",
"dependencies": {
"lodash": "^3.10.0",
"lodash": "3.10.0",
"node-css": "0.1.0"
},
"devDependencies": {
"babel-eslint": "^4.0.5",
"chai": "^3.0.0",
"coveralls": "^2.11.3",
"eslint": "^1.0.0",
"eslint-config-airbnb": "0.0.7",
"eslint-plugin-react": "^3.1.0",
"gulp": "^3.9.0",
"gulp-istanbul": "^0.10.0",
"gulp-mocha": "^2.1.3",
"istanbul": "^0.3.17",
"jscs": "^2.0.0",
"mocha": "^2.2.5",
"mocha-lcov-reporter": "0.0.2"
"babel-eslint": "4.0.5",
"chai": "3.4.1",
"coveralls": "2.11.6",
"eslint": "1.10.3",
"eslint-config-airbnb": "3.1.0",
"eslint-plugin-react": "3.15.0",
"gulp": "3.9.0",
"gulp-istanbul": "0.10.3",
"gulp-mocha": "2.2.0",
"istanbul": "0.4.2",
"mocha": "2.3.4",
"mocha-lcov-reporter": "1.0.0"
}
}
Loading

0 comments on commit d70df35

Please sign in to comment.