1const { basename, extname } = require('path') 2 3const binaryExtensions = require('binary-extensions') 4 5// we should try to print patches as long as the 6// extension is not identified as binary files 7const shouldPrintPatch = (path, opts = {}) => { 8 if (opts.diffText) { 9 return true 10 } 11 12 const filename = basename(path) 13 const extension = ( 14 filename.startsWith('.') 15 ? filename 16 : extname(filename) 17 ).slice(1) 18 19 return !binaryExtensions.includes(extension) 20} 21 22module.exports = shouldPrintPatch 23