Created
November 25, 2021 15:09
-
-
Save vncsna/18fdb859a0503d1747072b96fbbc039a to your computer and use it in GitHub Desktop.
Create a `index.ts`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage `python create_ts_index.py <folder-name>` | |
# TODO: Convert to bash script | |
import sys | |
from pathlib import Path | |
def create_index(rootpath): | |
rootpath = Path(rootpath) | |
indexpath = rootpath / "index.ts" | |
indexpath.unlink(True) | |
with indexpath.open("w") as file: | |
for filename in sorted(rootpath.glob("*")): | |
if filename.name[:-3] != 'index': | |
file.write(f"export * from './{filename.name[:-3]}';\n") | |
if __name__ == "__main__": | |
rootpath = sys.argv[1] | |
create_index(rootpath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment