Skip to content

Commit

Permalink
fix: correct all the references to @create-index
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Nov 29, 2016
1 parent d7e2528 commit ab6c399
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ create-index --help

Options:
--update, -u Recursively iterates target directories looking for "index.js"
files that start with "'create index';\n" (create-index index
files that start with "// @create-index\n" (create-index index
file). Updates found index files. Does not create new index
files. [boolean] [default: false]

Expand Down Expand Up @@ -172,7 +172,7 @@ drwxr-xr-x 2 gajus staff 68B 6 Jan 15:29 foo
Given the above directory contents, `./index.js` will be:

```js
'create index';
// @create-index

import bar from './bar';
import foo from './foo.js';
Expand All @@ -187,6 +187,6 @@ When file has the same name as a sibling directory, file `import` takes preceden

Directories that do not have `./index.js` in themselves will be excluded.

When run again, `create-index` will update existing `./index.js` if it starts with `'create index';\n\n`.
When run again, `create-index` will update existing `./index.js` if it starts with `// @create-index\n\n`.

If `create-index` is executed against a directory that contains `./index.js`, which does not start with `'create index';\n\n`, an error will be thrown.
If `create-index` is executed against a directory that contains `./index.js`, which does not start with `// @create-index\n\n`, an error will be thrown.
4 changes: 2 additions & 2 deletions src/bin/create-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {
const argv = yargs
.demand(1)
.options({
'update': {
update: {
alias: 'u',
default: false,
description: 'Recursively iterates target directories looking for "index.js" files that start with "\'create index\';\\n" (create-index index file). Updates found index files. Does not create new index files.',
description: 'Recursively iterates target directories looking for "index.js" files that start with "// @create-index\\n" (create-index index file). Updates found index files. Does not create new index files.',
type: 'boolean'
}
})
Expand Down
3 changes: 1 addition & 2 deletions src/utilities/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'create index';
// @create-index

export createIndexCode from './createIndexCode.js';
export findIndexFiles from './findIndexFiles.js';
Expand All @@ -8,4 +8,3 @@ export sortByDepth from './sortByDepth.js';
export validateTargetDirectory from './validateTargetDirectory.js';
export writeIndex from './writeIndex.js';
export writeIndexCli from './writeIndexCli.js';

10 changes: 5 additions & 5 deletions test/createIndexCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ describe('createIndexCode()', () => {
const indexCode = createIndexCode([]);

expect(indexCode).to.equal(codeExample(`
'create index';
// @create-index
`));
});
it('describes a single child', () => {
const indexCode = createIndexCode(['foo']);

expect(indexCode).to.equal(codeExample(`
'create index';
// @create-index
export foo from './foo';
`));
Expand All @@ -27,7 +27,7 @@ export foo from './foo';
const indexCode = createIndexCode(['bar', 'foo']);

expect(indexCode).to.equal(codeExample(`
'create index';
// @create-index
export bar from './bar';
export foo from './foo';
Expand All @@ -38,7 +38,7 @@ export foo from './foo';
const indexCode = createIndexCode(['foo.js']);

expect(indexCode).to.equal(codeExample(`
'create index';
// @create-index
export foo from './foo.js';
`));
Expand All @@ -49,7 +49,7 @@ export foo from './foo.js';
const indexCode = createIndexCode(['foo', 'bar']);

expect(indexCode).to.equal(codeExample(`
'create index';
// @create-index
export bar from './bar';
export foo from './foo';
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/write-index/mixed/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'create index';
// @create-index

export bar from './bar';
export foo from './foo.js';
Expand Down
2 changes: 1 addition & 1 deletion test/writeIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('writeIndex()', () => {
const indexCode = fs.readFileSync(indexFilePath, 'utf8');

expect(indexCode).to.equal(codeExample(`
'create index';
// @create-index
export bar from './bar';
export foo from './foo.js';
Expand Down

0 comments on commit ab6c399

Please sign in to comment.