Skip to content

converting .json with linked image files #982

Answered by iway1
iway1 asked this question in Q&A
Discussion options

You must be logged in to vote

Was able to create a script for it - just replace the p property with the base 64:

import fs from "node:fs";
import { program } from "commander";

program
  .option("-i, --injectFile <inject file>", "Destination file")
  .option("-s, --sourceDir <source directory>", "Source directory")
  .option("-o, --outputFile <output directory>", "Inject file");

type OptionsType = {
  injectFile?: string;
  sourceDir?: string;
};

type PartialLottieFile = {
  assets: { p: string }[];
};

program.parse();

const options = program.opts() as OptionsType;
if (!(options.injectFile && options.sourceDir))
  throw new Error("Pass all options plz.");

const dir = fs.readdirSync(options.sourceDir);
const overw…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by iway1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant