马宇豪
2024-07-16 f591c27b57e2418c9495bc02ae8cfff84d35bc18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const checkBin = require('./check-bin.js')
const normalize = require('npm-normalize-package-bin')
const checkBins = async ({ pkg, path, top, global, force }) => {
  // always ok to clobber when forced
  // always ok to clobber local bins, or when forced
  if (force || !global || !top) {
    return
  }
 
  pkg = normalize(pkg)
  if (!pkg.bin) {
    return
  }
 
  await Promise.all(Object.keys(pkg.bin)
    .map(bin => checkBin({ bin, path, top, global, force })))
}
module.exports = checkBins