synapsecns/sanguine

View on GitHub
packages/synapse-interface/scripts/utils/prettyPrintTs.js

Summary

Maintainability
A
0 mins
Test Coverage
const fs = require('fs')
const { execSync } = require('child_process')

// Writes map export to a TypeScript file, then runs prettier on the file
const prettyPrintTS = (map, mapName, fn) => {
  console.log(`Writing ${mapName} to ${fn}`)
  const json = JSON.stringify(map)
  fs.writeFileSync(fn, `export const ${mapName} = ${json}`)
  // Run prettier on the file using terminal command:
  execSync(`npx prettier --write ${fn}`)
}

module.exports = { prettyPrintTS }