Skip to content

Commit

Permalink
v2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mishanga committed Jan 9, 2014
2 parents cac347b + 1ca36ae commit 9479465
Show file tree
Hide file tree
Showing 215 changed files with 1,180 additions and 1,741 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
lib-cov
node_modules
test/test-coverage.html

.idea
*.iml
Expand Down
3 changes: 2 additions & 1 deletion .jscs.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"excludeFiles": [
"node_modules/**"
"node_modules/**",
"lib-cov/**"
],
"requireCurlyBraces": [
"else",
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 2.0.2 - 2014-01-09
- Added test coverage (#138)
- Added test helpers (#147)
- Fixed config file recursive searching (#151)
- Fixed `block-indent` detecting (#148)
- Fixed `quote` value setter (#149)
- Fixed detection integral tests (#150)

## 2.0.1 - 2013-12-23
- Fix for `remove-empty-rulesets` option (#133)

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,14 @@ a
Run `npm test` for tests.
To check test coverage, you need `jscoverage` tool.
Once it is installed ([see instructions here](https://github.com/visionmedia/node-jscoverage#installation)), run:
```
npm run-script test-cov
open ./test/test-coverage.html
```
## Contributing
Anyone and everyone is welcome to contribute. Please take a moment to
Expand Down
16 changes: 11 additions & 5 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,26 @@ function getConfigPath(configPath) {
var HOME = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
// Since `process.cwd()` can be absolutely anything, build default path
// relative to current directory:
var defaultConfigPath = __dirname + '/../config/csscomb.json';
var defaultConfigPath = path.join(__dirname, '../config/csscomb.json');

configPath = configPath || process.cwd() + '/.csscomb.json';
configPath = configPath || path.join(process.cwd(), '.csscomb.json');

// If we've finally found a config, return its path:
if (fs.existsSync(configPath)) return configPath;

// If we are in HOME dir already and yet no config file, return a default
// one from our package:
if (path.dirname(configPath) === HOME) return defaultConfigPath;
// one from our package.
// If project is located not under HOME, compare to root instead.
// Since there appears to be no good way to get root path in
// Windows, assume that if current dir has no parent dir, we're in
// root.
var dirname = path.dirname(configPath);
var parentDirname = path.dirname(dirname);
if (dirname === HOME || dirname === parentDirname) return defaultConfigPath;

// If there is no config in this directory, go one level up and look for
// a config there:
configPath = path.dirname(path.dirname(configPath)) + '/.csscomb.json';
configPath = path.join(parentDirname, '.csscomb.json');
return getConfigPath(configPath);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/options/block-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module.exports = {
detect: function(nodeType, node, level) {
var result = null;
if (nodeType === 'atrulers' || nodeType === 'block') {
if (node[node.length - 1][0] === 's' && level > 0) {
if (node.length && node[node.length - 1][0] === 's' && level > 0) {
result = node[node.length - 1][1].replace(/\s*\n/g, '');

if (this._prev !== undefined && this._prev[0] < level) {
Expand Down
2 changes: 2 additions & 0 deletions lib/options/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module.exports = {
* @returns {Object|undefined}
*/
setValue: function(value) {
delete this._value;

if (value === 'single' || value === 'double' ) {
this._value = value;
}
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "csscomb",
"description": "CSS coding style formatter",
"version": "2.0.1",
"version": "2.0.2",
"homepage": "http://csscomb.com/",
"author": "Mikhail Troshev <[email protected]>",
"repository": "https://github.com/csscomb/csscomb.js",
Expand Down Expand Up @@ -45,7 +45,7 @@
},
"dependencies": {
"commander": "2.0.0",
"gonzales-pe": "2.0.1",
"gonzales-pe": "2.0.x",
"minimatch": "0.2.12",
"vow": "0.3.11",
"vow-fs": "0.2.3"
Expand All @@ -61,6 +61,7 @@
"csscomb": "./bin/csscomb"
},
"scripts": {
"test": "./node_modules/.bin/jshint-groups && ./node_modules/.bin/jscs . && ./node_modules/.bin/mocha -u bdd -R dot"
"test": "./node_modules/.bin/jshint-groups && ./node_modules/.bin/jscs . && node test/mocha",
"test-cov": "rm -rf lib-cov && jscoverage lib lib-cov && TEST_COV=true node test/mocha > ./test/test-coverage.html"
}
}
100 changes: 0 additions & 100 deletions test/always-semicolon-less.js

This file was deleted.

108 changes: 0 additions & 108 deletions test/always-semicolon-scss.js

This file was deleted.

2 changes: 1 addition & 1 deletion test/configure.js → test/core/configure.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Comb = require('../lib/csscomb');
var Comb = process.env.TEST_COV ? require('../../lib-cov/csscomb') : require('../../lib/csscomb');
var assert = require('assert');

describe('csscomb methods', function() {
Expand Down
51 changes: 51 additions & 0 deletions test/core/get-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
var assert = require('assert');

describe('csscomb methods', function() {
it('getConfig()', function() {
var config = require('../../config/csscomb.json');

assert.equal(this.comb.getConfig(), config);
});

it('getConfig(number)', function() {
assert.throws(function() {
this.comb.getConfig(16);
});
});

it('getConfig(boolean)', function() {
assert.throws(function() {
this.comb.getConfig(true);
});
});

it('getConfig(empty string)', function() {
var config = require('../../config/csscomb.json');

assert.equal(this.comb.getConfig(''), config);
});

it('getConfig(invalid string)', function() {
assert.throws(function() {
this.comb.getConfig('nani');
});
});

it('getConfig(csscomb)', function() {
var config = require('../../config/csscomb.json');

assert.equal(this.comb.getConfig('csscomb'), config);
});

it('getConfig(zen)', function() {
var config = require('../../config/zen.json');

assert.equal(this.comb.getConfig('zen'), config);
});

it('getConfig(yandex)', function() {
var config = require('../../config/yandex.json');

assert.equal(this.comb.getConfig('yandex'), config);
});
});
Loading

0 comments on commit 9479465

Please sign in to comment.