feat: add ignore option (fix #31) (#37)

- Add functionality to ignore files based on provided
regular expressions
- Support writeIndex and writeIndexCli
- in index.js config must be specified as below

    // @create-index {"ignore":["/foo.js"]}
This commit is contained in:
Dawid Karabin
2017-03-13 20:42:46 +00:00
committed by Gajus Kuizinas
parent 5fea5e63d7
commit bf45925380
20 changed files with 257 additions and 39 deletions
+6 -1
View File
@@ -5,6 +5,7 @@ import chalk from 'chalk';
import createIndexCode from './createIndexCode';
import validateTargetDirectory from './validateTargetDirectory';
import readDirectory from './readDirectory';
import readIndexConfig from './readIndexConfig';
import sortByDepth from './sortByDepth';
import log from './log';
import findIndexFiles from './findIndexFiles';
@@ -44,13 +45,17 @@ export default (directoryPaths, options = {}) => {
_.forEach(sortedDirectoryPaths, (directoryPath) => {
let existingIndexCode;
const config = readIndexConfig(directoryPath);
const siblings = readDirectory(directoryPath, {
config,
extensions: options.extensions,
silent: options.ignoreUnsafe
});
const indexCode = createIndexCode(siblings, {
banner: options.banner
banner: options.banner,
config
});
const indexFilePath = path.resolve(directoryPath, 'index.js');