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
+21 -5
View File
@@ -12,7 +12,7 @@ describe('createIndexCode()', () => {
expect(indexCode).to.equal(codeExample(`
// @create-index
`));
`));
});
it('describes a single child', () => {
const indexCode = createIndexCode(['foo']);
@@ -21,7 +21,7 @@ describe('createIndexCode()', () => {
// @create-index
export { default as foo } from './foo';
`));
`));
});
it('describes multiple children', () => {
const indexCode = createIndexCode(['bar', 'foo']);
@@ -31,7 +31,7 @@ export { default as foo } from './foo';
export { default as bar } from './bar';
export { default as foo } from './foo';
`));
`));
});
context('file with extension', () => {
it('removes the extension from the export statement', () => {
@@ -41,7 +41,7 @@ export { default as foo } from './foo';
// @create-index
export { default as foo } from './foo.js';
`));
`));
});
});
context('multiple, unsorted', () => {
@@ -53,7 +53,23 @@ export { default as foo } from './foo.js';
export { default as bar } from './bar';
export { default as foo } from './foo';
`));
`));
});
});
context('with config', () => {
it('should append config', () => {
const config = {
ignore: ['/^zoo/']
};
const indexCode = createIndexCode(['foo', 'bar'], {config});
expect(indexCode).to.equal(codeExample(`
// @create-index {"ignore":["/^zoo/"]}
export { default as bar } from './bar';
export { default as foo } from './foo';
`));
});
});
});