Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use "replaceall" for relative -> absolute path replacement #35

Merged
merged 1 commit into from
Mar 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);