Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TypeScript/index.ts compatibility #1

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"plugins": [
"transform-es2015-modules-commonjs",
"transform-export-extensions",
"transform-es2015-destructuring",
"transform-es2015-parameters"
"@babel/plugin-transform-modules-commonjs",
"@babel/plugin-proposal-export-default-from",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-transform-destructuring",
"@babel/plugin-transform-parameters"
]
}
6 changes: 4 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
./test/fixtures
test/fixtures
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ node_js:
- 7
- 6
- 5
script:
- npm run lint
- npm run test
- npm run build
after_success:
- semantic-release pre && npm publish && semantic-release post
- semantic-release
notifications:
email: false
sudo: false
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2016, Gajus Kuizinas (http://gajus.com/)
Copyright (c) 2020, Gajus Kuizinas (http://gajus.com/)
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
52 changes: 33 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ This created `index.js` with:
```js
// @create-index

export { default as bar } from './bar.js';
export { default as foo } from './foo.js';
export { default as Bar } from './bar.js';
export { default as Foo } from './foo.js';

```

Expand Down Expand Up @@ -66,9 +66,9 @@ This have updated `index.js` file:
```js
// @create-index

export { default as bar } from './bar.js';
export { default as Bar } from './bar.js';
export { default as baz } from './baz.js';
export { default as foo } from './foo.js';
export { default as Foo } from './foo.js';

```

Expand All @@ -82,21 +82,35 @@ npm install create-index
create-index --help

Options:
--recursive, -r Create/update index files recursively. Halts on any unsafe
"index.js" files. [boolean] [default: false]
--ignoreUnsafe, -i Ignores unsafe "index.js" files instead of halting.
--recursive, -r Create/update index files recursively. Halts on any
unsafe "index.js" files. [boolean] [default: false]
--ignoreUnsafe, -i Ignores unsafe "index.js" files instead of halting.
[boolean] [default: false]
--update, -u Updates only previously created index files (recursively).
--ignoreDirectories, -d Ignores importing directories into the index file,
even if they have a safe "index.js".
[boolean] [default: false]
--banner Add a custom banner at the top of the index file [string]
--update, -u Updates only previously created index files
(recursively). [boolean] [default: false]
--banner Add a custom banner at the top of the index file
[string]
--extensions, -x Allows some extensions to be parsed as valid source.
First extension will always be preferred to homonyms
with another allowed extension.
[array] [default: ["js"]]
--outputFile, -o Output file [string] [default: "index.js"] [array] [default: ["js"]]

Examples:
create-index ./src ./src/utilities Creates or updates an existing
create-index index file in the target
(./src, ./src/utilities) directories.
create-index --update ./src ./tests Finds all create-index index files in the
target directories and descending
directories. Updates found index files.
create-index ./src ./src/utilities Creates or updates an existing
create-index index file in the target
(./src, ./src/utilities) directories.
create-index --update ./src ./tests Finds all create-index index files in
the target directories and descending
directories. Updates found index
files.
create-index ./src --extensions js jsx Creates or updates an existing
create-index index file in the target
(./src) directory for both .js and
.jsx extensions.
```

### Using `create-index` Programmatically
Expand Down Expand Up @@ -177,8 +191,8 @@ Given the above directory contents, `./index.js` will be:
```js
// @create-index

import { default as bar } from './bar';
import { default as foo } from './foo.js';
import { default as Bar } from './bar';
import { default as Foo } from './foo.js';

export {
bar,
Expand Down Expand Up @@ -219,8 +233,8 @@ Given the above directory contents, after running `create-index` with `--update`
```js
// @create-index {"ignore": ["/baz.js$/"]}

import { default as bar } from './bar.js';
import { default as foo } from './foo.js';
import { default as Bar } from './bar.js';
import { default as Foo } from './foo.js';

export {
bar,
Expand Down
26 changes: 21 additions & 5 deletions dist/bin/create-index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/bin/create-index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions dist/utilities/constants.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/utilities/constants.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 24 additions & 27 deletions dist/utilities/createIndexCode.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading