caffco/yarn-workspace-packages-github-action

View on GitHub
src/fs.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import fs from 'fs'

export const readJsonFile = async (
  pathToFile: string
): Promise<Record<string, unknown>> => {
  const buffer = await new Promise<Buffer>((resolve, reject) =>
    fs.readFile(pathToFile, (error, data) =>
      error ? reject(error) : resolve(data)
    )
  )

  return JSON.parse(buffer.toString())
}