<commit_before>const process = require('process')

const fs = require('fs')
const createVerge1PalLoader = require('../loader/createVerge1PalLoader')
const createVerge1Cr2Loader = require('../loader/createVerge1Cr2Loader')
const createVerge1Cr2Converter = require('../converter/createVerge1Cr2Converter')

const palFilename = process.argv[2]
const cr2Filename = process.argv[3]

fs.readFile(palFilename, (err, diskPalData) => {
  const palLoader = createVerge1PalLoader({data: diskPalData})
  const palData = palLoader.load()

  fs.readFile(cr2Filename, (err, diskCr2Data) => {
    const cr2Loader = createVerge1Cr2Loader({data: diskCr2Data})
    const cr2Data = cr2Loader.load()
    const cr2Converter = createVerge1Cr2Converter({
      palette: palData.pal,
      chr2: cr2Data.chr2,
    })

    const png = cr2Converter.convertToPng()
    const targetFilename = cr2Filename + '.png'

    png.pack().pipe(fs.createWriteStream(targetFilename))

    console.log('converted', cr2Filename, 'to', targetFilename)
  })
})<commit_msg>use sync file readers in cli<commit_after>const process = require('process')

const fs = require('fs')
const createVerge1PalLoader = require('../loader/createVerge1PalLoader')
const createVerge1Cr2Loader = require('../loader/createVerge1Cr2Loader')
const createVerge1Cr2Converter = require('../converter/createVerge1Cr2Converter')

const palFilename = process.argv[2]
const cr2Filename = process.argv[3]

const diskPalData = fs.readFileSync(palFilename)
const palLoader = createVerge1PalLoader({data: diskPalData})
const palData = palLoader.load()

const diskCr2Data = fs.readFileSync(cr2Filename)
const cr2Loader = createVerge1Cr2Loader({data: diskCr2Data})
const cr2Data = cr2Loader.load()
const cr2Converter = createVerge1Cr2Converter({
  palette: palData.pal,
  chr2: cr2Data.chr2,
})

const png = cr2Converter.convertToPng()
const targetFilename = cr2Filename + '.png'

png.pack().pipe(fs.createWriteStream(targetFilename))

console.log('converted', cr2Filename, 'to', targetFilename)
{'fraction_non_alphanumeric': 0.12097174020823004, 'fraction_numerical': 0.030738720872583045, 'mean_word_length': 6.055944055944056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1412706', 'n_tokens_mistral': 654, 'n_tokens_neox': 646, 'n_words': 125}