https://github.com/eibens/module_gen
https://github.com/eibens/module_gen
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/eibens/module_gen
- Owner: eibens
- License: mit
- Created: 2022-07-29T06:46:56.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-07-29T06:47:34.000Z (almost 3 years ago)
- Last Synced: 2025-01-22T13:48:00.913Z (5 months ago)
- Language: TypeScript
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eibens/module_gen
Utilities for generating generic TypeScript modules for
[Deno](https://deno.land).[](LICENSE)
[](https://github.com/eibens/module_gen)
[](https://github.com/eibens/module_gen/actions/workflows/ci.yml)## Usage
Assume a project has a `utils` folder with a bunch of directories and top-level
TypeScript files.```txt
- utils
- hello
- mod.ts
- world
- mod.ts
- foo.ts
- bar.ts
```The provided functions can scan the `utils` directory for sub-directories and
for top-level TypeScript files and generate a new `utils/mod.ts` module.```ts
import { exportAllFromFiles, write } from "./mod.ts";await write(
import.meta.resolve("./utils/mod.ts"),
exportAllAsNameFromDirs(import.meta.resolve("./utils")),
exportAllFromFiles(import.meta.resolve("./utils")),
);
```After running the code above, the `utils/mod.ts` module will contain exports for
all module files.```ts
// Generated code. Do not edit.
export * as hello from "./hello/mod.ts";
export * as world from "./world/mod.ts";
export * from "./bar.ts";
export * from "./foo.ts";
```Take a look into the [example](example) folder to see this in action.
## Future Work
This is still an early prototype. It does not support file patterns, custom
extensions, reliable detection of modules, and probably a lot of other common
options and features.