1const { read } = require('fs')
2const readJsonFile = file => {
3 if (file.split('.')[file.split('.').length - 1] !== 'json') return {}
4
5 const fileContent = read(file)
6
7 if (!fileContent) return {}
8
9 return JSON.parse(fileContent)
10}
11readJsonFile('package.json')