Docs.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
[](https://travis-ci.org/gajus/create-index)
|
||||
[](https://github.com/gajus/canonical)
|
||||
|
||||
`create-index` program creates ES6 `./index.js` file in target directories that imports and exports all sibling files and directories.
|
||||
`create-index` program creates (and maintains) ES6 `./index.js` file in target directories that imports and exports sibling files and directories.
|
||||
|
||||
## Implementation
|
||||
|
||||
@@ -18,7 +18,7 @@ If there is no `./index.js`, it will create a new file, e.g.
|
||||
|
||||
Created index file must start with `'create index';\n\n`. This is used to make sure that `create-index` does not accidentally overwrite your local files.
|
||||
|
||||
If there are sibling files, index file will import them and export, e.g.
|
||||
If there are sibling files, index file will `import` them and `export`, e.g.
|
||||
|
||||
```sh
|
||||
children-directories-and-files git:(master) ✗ ls -lah
|
||||
@@ -30,7 +30,7 @@ drwxr-xr-x 2 gajus staff 68B 6 Jan 15:29 foo
|
||||
-rw-r--r-- 1 gajus staff 0B 6 Jan 15:29 foo.js
|
||||
```
|
||||
|
||||
Given the above directory contents, index will be:
|
||||
Given the above directory contents, `./index.js` will be:
|
||||
|
||||
```js
|
||||
'create index';
|
||||
@@ -44,13 +44,19 @@ export {
|
||||
};
|
||||
```
|
||||
|
||||
If there are files with the same name as directories in the same directory, file will take precedence.
|
||||
When file has the same name as a sibling directory, file `import` takes precedence.
|
||||
|
||||
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`.
|
||||
|
||||
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.
|
||||
|
||||
## Using CLI Program
|
||||
|
||||
```sh
|
||||
npm install create-index
|
||||
|
||||
create-index ./directory1 ./directory2 ./directory3 ...
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user