diff --git a/README.md b/README.md index 1973099..33fa90f 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 ``` diff --git a/lib/data/root.js b/lib/data/root.js index f68150d..dc00b86 100644 --- a/lib/data/root.js +++ b/lib/data/root.js @@ -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); @@ -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() diff --git a/lib/utils/args.js b/lib/utils/args.js index 0900223..e4dca02 100644 --- a/lib/utils/args.js +++ b/lib/utils/args.js @@ -12,6 +12,7 @@ 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') @@ -19,6 +20,7 @@ const argv = require('yargs') .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') @@ -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]; });