ts-index-builder
v1.0.2
Published
Index files builder for TypeScript sources
Downloads
122
Readme
ts-index-builder
Install
Locally (recommended)
npm install --save-dev ts-index-builder
Globally
npm install -g ts-index-builder
Usage
CLI
You can use it in the scripts
of your package.json
{
"main": "dist/index.js",
"scripts": {
"build": "ts-index-builder && tsc --project ."
},
"devDependencies": {
"ts-index-builder": "^1.0.0"
}
}
You can also use it manually :
# If installed globally
ts-index-builder
# If installed locally
./node_modules/bin/ts-index-builder
In code
import buildIndexes from 'ts-index-builder'
(async () => {
await buildIndexes({
directory: 'lib',
subIndexes: true,
});
})();
Options
directory
Type: String
Default: "src"
CLI option: -d <value>
, --directory <value>
Relative path to the directory containing the TypeScript sources and in which the index files will be created.
include
Type: String[]
Default: ["**/*.ts"]
CLI option: -i <value>
, --include <value>
The paths of the files (relative to directory
) must match ONE of these globs to be included
(directories are browsed EVEN if they don't match, but their content will be ignored if it doesn't match)
exclude
Type: String[]
Default: ["**/*.spec.ts"]
CLI option: -e <value>
, --exclude <value>
The paths of the files (relative to directory
) must NOT match ANY of these globs to be included
(directories are NOT browsed if they match)
modules
Type: String[]
Default: []
CLI option: -m <value>
, --modules <value>
For directories whose relative paths match the modules
globs, an index is created in the directory, but not included in the parent indexes.
This allows imports of subdirectories (i.e.: import * as myLibAuth from "my-lib/auth"
)
subIndexes
Type: Boolean
Default: false
CLI option: -u
, --sub-indexes
If enabled, generate indexes for all (sub-)directories (and include them in parent indexes)
version
Type: Boolean
Default: false
CLI option: -v
, --version
Print version
help
Type: Boolean
Default: false
CLI option: -h
, --help
Print this help
Globs
For documentation on the glob implementation used by this package, see the glob or minimatch packages.