Skip to content

Commit

Permalink
feat(general): allow hidden folders validation
Browse files Browse the repository at this point in the history
Closes #176
  • Loading branch information
buchslava committed Jul 13, 2016
1 parent d24b18c commit 955c21b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Options:
-j Fix wrong JSONs
--rules print information regarding supported rules
--indexless forget about ddf--index.csv and validate
--hidden allow hidden folders validation
--include-tags Process only issues by selected tags
--exclude-tags Process all tags except selected
--include-rules Process only issues by selected rules
Expand All @@ -35,6 +36,7 @@ Examples:
validate-ddf ../ddf-example -j fix JSONs for this DDF dataset
validate-ddf --rules print information regarding supported rules
validate-ddf ../ddf-example --indexless forget about ddf--index.csv and validate
validate-ddf ../ddf-example --hidden allow hidden folders validation
validate-ddf ../ddf-example --include-rules "INCORRECT_JSON_FIELD" Validate only by INCORRECT_JSON_FIELD rule
validate-ddf ../ddf-example --exclude-tags "WARNING" Get all kinds of issues except warnings
```
Expand Down
8 changes: 6 additions & 2 deletions lib/data/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ function isExcludedDirectory(currentDirectory, excludedDirectory) {
return EXCLUDED_DIRECTORY_PATTERN.test(currentDirectory);
}

function isHiddenDirectory(currentDirectory) {
function isHiddenDirectory(currentDirectory, settings) {
if (settings.isCheckHidden) {
return false;
}

const HIDDEN_DIRECTORY_PATTERN = new RegExp(`${pathModule.sep}\\.[^.${pathModule.sep}]`);

return HIDDEN_DIRECTORY_PATTERN.test(currentDirectory);
Expand All @@ -31,7 +35,7 @@ class DDFRoot {
const actions = [];

dirs.concat(this.path).forEach(dir => {
const isNotExcludedDirectory = !isHiddenDirectory(dir) &&
const isNotExcludedDirectory = !isHiddenDirectory(dir, this.settings) &&
_.chain(this.settings.excludeDirs)
.map(excludedDir => isExcludedDirectory(dir, excludedDir))
.compact()
Expand Down
17 changes: 12 additions & 5 deletions lib/utils/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ const argv = require('yargs')
.example(`${myName} ../ddf-example -j`, 'fix JSONs for this DDF dataset')
.example(`${myName} --rules`, 'print information regarding supported rules')
.example(`${myName} ../ddf-example --indexless`, 'forget about ddf--index.csv and validate')
.example(`${myName} ../ddf-example --hidden`, 'allow hidden folders validation')
.example(`${myName} ../ddf-example --include-rules "INCORRECT_JSON_FIELD"`,
'Validate only by INCORRECT_JSON_FIELD rule')
.example(`${myName} ../ddf-example --exclude-tags "WARNING_TAG"`, 'Get all kinds of issues except warnings')
.describe('i', 'Generate index file')
.describe('j', 'Fix wrong JSONs')
.describe('rules', 'print information regarding supported rules')
.describe('indexless', 'forget about ddf--index.csv and validate')
.describe('hidden', 'allow hidden folders validation')
.describe('include-tags', 'Process only issues by selected tags')
.describe('exclude-tags', 'Process all tags except selected')
.describe('include-rules', 'Process only issues by selected rules')
Expand All @@ -30,12 +32,17 @@ exports.getDDFRootFolder = () => argv._[0] || process.cwd();
exports.getSettings = () => {
const settings = {};
const options = ['include-tags', 'exclude-tags', 'include-rules', 'exclude-rules', 'exclude-dirs'];
const setMiscSettings = () => {
settings.isUI = false;
settings.isIndexGenerationMode = !!argv.i;
settings.isJsonAutoCorrectionMode = !!argv.j;
settings.indexlessMode = !!argv.indexless;
settings.isPrintRules = !!argv.rules;
settings.isCheckHidden = !!argv.hidden;
};

setMiscSettings();

settings.isUI = false;
settings.isIndexGenerationMode = !!argv.i;
settings.isJsonAutoCorrectionMode = !!argv.j;
settings.indexlessMode = !!argv.indexless;
settings.isPrintRules = !!argv.rules;
options.forEach(option => {
settings[_.camelCase(option)] = argv[option];
});
Expand Down

0 comments on commit 955c21b

Please sign in to comment.