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

Take correctly in account --ignorepattern option #35

Merged
merged 1 commit into from
Apr 30, 2020
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [4.5.3] 2020-04-30

- Fixes
- ignorepattern option not working [#34](https://github.com/nvuillam/npm-groovy-lint/issues/34)

## [4.5.2] 2020-04-29

- Expose `loadConfig()` method to load rules when npm-groovy-lint is used as a library
Expand Down
5 changes: 5 additions & 0 deletions src/codenarc-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ async function prepareCodeNarcCall(options) {
result.codenarcArgs.push('-includes="' + defaultFilesPattern + '"');
}

// Ignore pattern
if (options.ignorepattern) {
result.codenarcArgs.push('-excludes="' + options.ignorepattern + '"');
}

// Output
result.output = options.output.replace(/^"(.*)"$/, "$1");
if (["txt", "json", "none"].includes(result.output) || result.output.endsWith(".txt") || result.output.endsWith(".json")) {
Expand Down
15 changes: 14 additions & 1 deletion test/lint-build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const spawn = childProcess.spawnSync;

const { SAMPLE_FILE_SMALL, NPM_GROOVY_LINT } = require('./helpers/common');

describe('Lint with executables (jdeploy-bundle)', () => {
describe('Lint with executable (jdeploy-bundle)', () => {
it('(EXE:file) should generate text console output', async () => {
const params = [
'--path', '"jdeploy-bundle/lib/example"',
Expand Down Expand Up @@ -38,6 +38,19 @@ describe('Lint with executables (jdeploy-bundle)', () => {
assert(stdout.includes(`"totalFoundWarningNumber":`), 'Property totalFoundWarningNumber is in result');
});

it('(EXE:file) should ignore node_modules pattern', async () => {
const params = [
'--ignorepattern', '**/node_modules/**',
'--output', 'txt'
];
const { stdout, stderr } = await exec('cd jdeploy-bundle/lib/example && ' + NPM_GROOVY_LINT + params.join(' '));
if (stderr) {
console.error(stderr);
}
assert(stdout, 'stdout is set');
assert(!stdout.includes(`ToIgnore.groovy`), 'ToIgnore.groovy has been ignored');
});

it('(EXE:file) should generate codenarc HTML file report', async () => {
const params = [
'--codenarcargs',
Expand Down