export const testDocument = (doc) =>
  doc.fileExtname.match(/(json|yml)$/i)

export const decorate = (doc) =>
  Object.assign(doc, {
    readDataSync() {
      if(doc.fileExtname === '.json') {
        return Object.assign({id: doc.id}, doc.project.readJsonSync(doc.path))
      } else if (doc.fileExtname === '.yml') {
        return require('js-yaml').safeLoad(doc.readFile().getFileContents())
      }
    }
  })