<commit_before>import * as fs from "fs-extra";
import * as path from "path";
import * as lib from "../..";
import generateIndexes from "./indexes";

export default async function execute(args: string[]): Promise<boolean> {
    if (args.length === 0) {
        console.error("Usage: eta generate module <name>");
        return false;
    }
    const moduleName: string = args[0];
    const moduleDir: string = lib.WORKING_DIR + "/modules/" + moduleName;
    if (await fs.pathExists(moduleDir)) {
        console.error("Module " + moduleName + " already exists.");
        return false;
    }
    console.log("Initializing module " + moduleName + "...");
    await fs.mkdirp(moduleDir);
    await fs.copy(lib.CLI_DIR + "/module-template", moduleDir + "/", { recursive: true });
    const fixJsonName = (obj: any) => {
        obj.name = moduleName;
        return obj;
    };
    await lib.transformJsonFile(moduleDir + "/eta.json", fixJsonName);
    await lib.transformJsonFile(moduleDir + "/package.json", fixJsonName);
    await generateIndexes([]);
    await lib.exec("git init", { cwd: moduleDir });
    await lib.exec("git add .", { cwd: moduleDir });
    await lib.exec(`git commit -m "Initial module setup"`, { cwd: moduleDir });
    return true;<commit_msg>Fix problem in `generate module`<commit_after>import * as fs from "fs-extra";
import * as path from "path";
import * as lib from "../..";
import generateIndexes from "./indexes";

export default async function execute(args: string[]): Promise<boolean> {
    if (args.length === 0) {
        console.error("Usage: eta generate module <name>");
        return false;
    }
    const moduleName: string = args[0];
    const moduleDir: string = lib.WORKING_DIR + "/modules/" + moduleName;
    if (await fs.pathExists(moduleDir)) {
        console.error("Module " + moduleName + " already exists.");
        return false;
    }
    console.log("Initializing module " + moduleName + "...");
    await fs.mkdirp(moduleDir);
    await fs.copy(lib.CLI_DIR + "/module-template", moduleDir + "/", { recursive: true });
    const fixJsonName = (obj: any) => {
        obj.name = moduleName;
        return obj;
    };
    await lib.transformJsonFile(moduleDir + "/eta.json", fixJsonName);
    await lib.transformJsonFile(moduleDir + "/package.json", fixJsonName);
    if (await fs.pathExists(moduleDir + "/.npmignore")) {
        await fs.move(moduleDir + "/.npmignore", moduleDir + "/.gitignore");
    }
    await generateIndexes([]);
    await lib.exec("git init", { cwd: moduleDir });
    await lib.exec("git add .", { cwd: moduleDir });
    await lib.exec(`git commit -m "Initial module setup"`, { cwd: moduleDir });
    return true;
{'fraction_non_alphanumeric': 0.15650557620817843, 'fraction_numerical': 0.001486988847583643, 'mean_word_length': 3.1463790446841293, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5299995', 'n_tokens_mistral': 806, 'n_tokens_neox': 816, 'n_words': 220}