how to upload file in folder using cli in nodeJs

I am trying to make a CLI which upload only specific .extension file for Example if I want to upload .jpg file then only JPG file should be uploaded by making JPG folder

const { program } = require("commander");

const fs = require("fs");
const path = require("path");

program.version("0.0.1");

program
  .command("file")
  .alias("f")
  .description("Add filename with filepath")
  .action(() => {
    prompt(questions).then((answers) => {
      try {
        // compare extension
        const extension = path.extname(answers.fileName);
        const allowedExtension = ".jpg";

        if (allowedExtension !== extension) {
          console.log("Use only .jpg Extension file");
        } else {
          // make dir
          fs.mkdir(path.join(__dirname, "JPG"), { recursive: true }, (err) => {
            if (err) {
              return console.error(err);
            }

            // read file or uploaded file
            const file = fs.createReadStream(
              `${answers.filePath}/${answers.fileName}`
            );
            console.log(
              "Directory created successfully!",
              answers.fileName,
              answers.filePath
            );
          });
        }
      } catch (error) {
        console.log(error.message);
      }
    });
  });

program.parse(process.argv);

but don’t know how to upload file by using CLI in the provided folder