<commit_before>import fg from "fast-glob";
import path from "path";

// FIXME
// eslint-disable-next-line
const svgexport = require("svgexport");
// eslint-disable-next-line
const mkdirp = require("mkdirp");

const INPUT_DIR = "./font-awesome/svgs";
const INPUT_SVG_PATHS = fg.sync(`${INPUT_DIR}/**/*.svg`);
const OUTPUT_DIR = "./assets/icons";
const PARAMS = "pad 128:128";

const outputPath = (inputPath: string): string => {
  const outputDir = path.parse(inputPath.replace(INPUT_DIR, OUTPUT_DIR)).dir;
  const name = path.parse(inputPath).name;
  return `${outputDir}/${name}.png`;
};

type TSvg = Readonly<{
  input: string; // e.g. "./font-awesome/svgs/**/*.svg"
  output: string; // e.g. "./assets/icons/**/*.png pad 300:300"
}>;

const SVGS: TSvg[] = INPUT_SVG_PATHS.map((inputPath: string) => {
  return {
    input: inputPath,
    output: `${outputPath(inputPath)} ${PARAMS}`,
  } as TSvg;
});

const makeDir = (svgs: TSvg[]): void => {
  const outputPaths = svgs.map((svg) => path.parse(svg.output).dir);
  const outputDirs = [...new Set(outputPaths)];

  outputDirs.forEach((dir) => mkdirp.sync(dir));
};

const convert = async (svgs: TSvg[]) => {
  return svgexport.render(svgs, process);
};

const main = () => {
  console.log("start svg2png");

  makeDir(SVGS);

  convert(SVGS.slice(0, 10)); // DEBUG
  // convert(SVGS);
};

main();<commit_msg>chore(utils): Comment out debug code in svg_to_png.ts<commit_after>import fg from "fast-glob";
import path from "path";

// FIXME
// eslint-disable-next-line
const svgexport = require("svgexport");
// eslint-disable-next-line
const mkdirp = require("mkdirp");

const INPUT_DIR = "./font-awesome/svgs";
const INPUT_SVG_PATHS = fg.sync(`${INPUT_DIR}/**/*.svg`);
const OUTPUT_DIR = "./assets/icons";
const PARAMS = "pad 128:128";

const outputPath = (inputPath: string): string => {
  const outputDir = path.parse(inputPath.replace(INPUT_DIR, OUTPUT_DIR)).dir;
  const name = path.parse(inputPath).name;
  return `${outputDir}/${name}.png`;
};

type TSvg = Readonly<{
  input: string; // e.g. "./font-awesome/svgs/**/*.svg"
  output: string; // e.g. "./assets/icons/**/*.png pad 300:300"
}>;

const SVGS: TSvg[] = INPUT_SVG_PATHS.map((inputPath: string) => {
  return {
    input: inputPath,
    output: `${outputPath(inputPath)} ${PARAMS}`,
  } as TSvg;
});

const makeDir = (svgs: TSvg[]): void => {
  const outputPaths = svgs.map((svg) => path.parse(svg.output).dir);
  const outputDirs = [...new Set(outputPaths)];

  outputDirs.forEach((dir) => mkdirp.sync(dir));
};

const convert = async (svgs: TSvg[]) => {
  return svgexport.render(svgs, process);
};

const main = () => {
  console.log("start svg2png");

  makeDir(SVGS);

  // convert(SVGS.slice(0, 10)); // DEBUG
  convert(SVGS);
};

main();
{'fraction_non_alphanumeric': 0.20217391304347826, 'fraction_numerical': 0.011594202898550725, 'mean_word_length': 4.131970260223048, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '1983084', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1019, 'n_words': 211}