Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Relative path resolving fix. Fixes #829
Browse files Browse the repository at this point in the history
  • Loading branch information
mdevils committed Dec 20, 2014
1 parent 5eb1541 commit 9aae17e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 16 deletions.
18 changes: 12 additions & 6 deletions lib/config/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,9 @@ Configuration.prototype.load = function(config) {

var overrides = this._overrides;
var currentConfig = {};
Object.keys(config).forEach(function(key) {
currentConfig[key] = config[key];
});
Object.keys(overrides).forEach(function(key) {
currentConfig[key] = overrides[key];
});

copyConfiguration(config, currentConfig);
copyConfiguration(overrides, currentConfig);

var ruleSettings = this._processConfig(currentConfig);
var processedSettings = {};
Expand Down Expand Up @@ -630,3 +627,12 @@ Configuration.prototype.registerDefaultPresets = function() {
};

module.exports = Configuration;

function copyConfiguration(source, dest) {
Object.keys(source).forEach(function(key) {
dest[key] = source[key];
});
if (source.configPath) {
dest.configPath = source.configPath;
}
}
20 changes: 17 additions & 3 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ var hooker = require('hooker');
var sinon = require('sinon');
var glob = require('glob');
var assert = require('assert');
var Vow = require('vow');
var hasAnsi = require('has-ansi');
var rewire = require('rewire');

Expand Down Expand Up @@ -41,7 +40,13 @@ describe('modules/cli', function() {

function assertNoCliErrors(vow) {
return vow.promise.always(function() {
assert(console.log.getCall(0).args[0] === 'No code style errors found.');
var stdout = process.stdout.write.getCall(0) ? process.stdout.write.getCall(0).args[0] : '';
var stderr = process.stderr.write.getCall(0) ? process.stderr.write.getCall(0).args[0] : '';
assert.equal(
stdout,
'No code style errors found.\n',
stderr
);
rAfter();
});
}
Expand Down Expand Up @@ -578,7 +583,7 @@ describe('modules/cli', function() {

it('should accept a relative path to a filter module', function() {
return assertNoCliErrors(cli({
errorFilter: './test/data/error-filter.js',
errorFilter: '../error-filter.js',
args: ['test/data/cli/error.js'],
config: 'test/data/cli/cli.json'
}));
Expand Down Expand Up @@ -627,4 +632,13 @@ describe('modules/cli', function() {
}));
});
});

describe('additionalRules', function() {
it('should correctly handle additionalRules paths', function() {
return assertNoCliErrors(cli({
args: ['test/data/cli/success.js'],
config: 'test/data/configs/additionalRules/.jscsrc'
}));
});
});
});
2 changes: 1 addition & 1 deletion test/data/cli/errorFilter.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"errorFilter": "./test/data/error-filter.js",
"errorFilter": "../error-filter.js",
"disallowKeywords": ["with"]
}
6 changes: 0 additions & 6 deletions test/data/configs/additionalRules/.jscs.json

This file was deleted.

6 changes: 6 additions & 0 deletions test/data/configs/additionalRules/.jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"successRule": true,
"additionalRules": [
"./success-rule.js"
]
}
12 changes: 12 additions & 0 deletions test/data/configs/additionalRules/success-rule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = function() {};

module.exports.prototype = {

configure: function() {},

getOptionName: function() {
return 'successRule';
},

check: function(file, errors) {}
};

0 comments on commit 9aae17e

Please sign in to comment.