Skip to content

Commit

Permalink
Merge pull request #35 from Turbo87/fix-paths-bug
Browse files Browse the repository at this point in the history
Use "replaceall" for relative -> absolute path replacement
  • Loading branch information
IanVS committed Mar 7, 2016
2 parents d873cd5 + f7e790f commit b9c47f7
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 2 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var CLIEngine = require('eslint').CLIEngine;
var chalk = require('chalk');
var globAll = require('glob-all');
var replaceAll = require("replaceall");
var cli = new CLIEngine({});


Expand Down Expand Up @@ -32,7 +33,7 @@ function test(p, opts) {
throw new Error(
chalk.red('Code did not pass lint rules') +
// remove process.cwd() to convert absolute to relative paths
formatter(report.results).replace(process.cwd() + '/', '')
replaceAll(process.cwd() + '/', '', formatter(report.results))
);
} else if (
warn &&
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"dependencies": {
"chalk": "^1.1.0",
"eslint": "^2.0.0",
"glob-all": "^3.0.1"
"glob-all": "^3.0.1",
"replaceall": "^0.1.6"
},
"devDependencies": {
"es6-promise": "^3.1.2",
Expand Down
16 changes: 16 additions & 0 deletions tests/acceptance/acceptanceTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ describe('Acceptance: mocha-eslint', function () {
});
});

it('should fail test for multiple-failing fixture', function () {
return runTest('tests/lint/multipleFailingLintTest.js').then(function (results) {
if (results[4].indexOf('1 failing') === -1) {
throw new Error('Did not get a failing test');
}

var reasonsCount = results[6].split('\n')
.filter(function(line) { return line.indexOf('Code did not pass lint rules') !== -1; })
.length;

if (reasonsCount !== 1) {
throw new Error('Counted ' + reasonsCount + " failure reasons");
}
});
});

it('should test multiple paths correctly', function () {
return runTest('tests/lint/multiplePathTest.js').then(function (results) {
if (results[3].indexOf('1 passing') === -1 ||
Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/multiple-failing/lintFail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

console.log("this should fail quote rule");
3 changes: 3 additions & 0 deletions tests/fixtures/multiple-failing/lintFailTwo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

console.log("this should fail quote rule");
8 changes: 8 additions & 0 deletions tests/lint/multipleFailingLintTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*eslint-env node, mocha */
'use strict';

var lint = require('../../index.js');
var paths = ['tests/fixtures/multiple-failing'];
var options = { formatter: 'stylish' };

lint(paths, options);

0 comments on commit b9c47f7

Please sign in to comment.