how to read json file with gluegun

JavaScript
module.exports = toolbox => {
  const {
    filesystem: { read }
  } = toolbox

  const readJsonFile = file => {
    if (file.split('.')[file.split('.').length - 1] !== 'json') return {}

    const fileContent = read(file)

    if (!fileContent) return {}

    return JSON.parse(fileContent)
  }

  toolbox.readJsonFile = readJsonFile
}

Source

Also in JavaScript: