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

Fixes: #23 #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: node_js
node_js:
- '6'
- '0.10'

script:
- npm test
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Options:
-I, --disable-ignore disables the ignore list
-r, --reporter [simple|detailed|json] specify reporter to use (default: simple)
-C, --no-color disables colors
-X, --exclude folders to exclude separated by comma
```

If a `.buddyrc` file is located in the project directory, its values will be
Expand All @@ -123,7 +124,8 @@ used in place of the defaults listed above. For example:
"detectObjects": false,
"enforceConst": false,
"ignore": [0, 1, 2], // Use empty array to disable ignore
"reporter": "detailed"
"reporter": "detailed",
"exclude":["git","node_modules"] // Use empty array to disable ignore
}
```

Expand Down
8 changes: 7 additions & 1 deletion bin/buddy
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ var program = require('commander');
var Detector = require('../lib/detector');
var reporters = require('../lib/reporters');

const excludePaths=function (excludedPaths) {
return excludedPaths.split(',');
}

program
.version(require('../package.json').version)
.usage('[options] <paths ...>')
Expand All @@ -19,8 +23,10 @@ program
.option('-r, --reporter [simple|detailed|json]',
'specify reporter to use (default: simple)')
.option('-C, --no-color', 'disables colors')
.option('-X --exclude <paths>','folders to exclude separated by comma ',excludePaths)
.parse(process.argv);


// Check and parse .buddyrc file, if it exists
var rcPath, rcContents, rc, opt;
rcPath = path.resolve(process.cwd(), '.buddyrc');
Expand Down Expand Up @@ -54,7 +60,7 @@ if (!program.color) {
try {
var paths = filepaths.getSync(suppliedPaths, {
suffix: '.js',
ignore: 'node_modules'
ignore: ['node_modules','git'].concat(program.exclude||[])
});
} catch(e) {
console.log(e.message);
Expand Down
279 changes: 279 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"bluebird": "*",
"chalk": "*",
"commander": "*",
"node-filepaths": "0.0.2",
"node-filepaths": "^0.1.0",
"strip-json-comments": "1.0.2"
},
"devDependencies": {
Expand Down
15 changes: 15 additions & 0 deletions spec/integration/buddySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,19 @@ describe('bin/buddy', function() {
done();
});
});
it('excludes fixtures and unit directory', function(done) {
// Absolute paths may vary
var expectedOutput = [
'No magic numbers found across 1 file'
];
exec('./bin/buddy -C -X fixtures,unit ./spec' , function(err, stdout, stderr) {
// Ignore err, since the command will fail due to detected
// magic numbers
expect(stderr).to.be.empty();
expectedOutput.forEach(function(str) {
expect(stdout).to.contain(str);
});
done();
});
});
});