codekingpro/portable-devtools
115k
1const { basename, extname } = require('node:path')
2
3// we should try to print patches as long as the
4// extension is not identified as binary files
5const shouldPrintPatch = async (path, opts = {}) => {
6 if (opts.diffText) {
7 return true
8 }
9
10 const { default: binaryExtensions } = await import('binary-extensions')
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 