🦷

【TypeScript】file.txt からtsファイル生成

2022/08/03に公開
import shutil
import sys

args = sys.argv
category = args[1]

f = open(f'{category}/files.txt', 'r')
data = f.read()
f.close()

for file in data.split("\n"):
    file = file.replace(" / ", "_")
    file = file.replace(" & ", "_")
    file = file.replace("-", "_")
    file = file.replace(" ", "_")
    file = file.lower()

    if len(file) > 0:
        shutil.copyfile("./tpl.test.ts", f"./{category}/{file}.test.ts")

Discussion