11cb0ef41Sopenharmony_ciconst isWindows = require('./is-windows.js') 21cb0ef41Sopenharmony_ciconst binTarget = require('./bin-target.js') 31cb0ef41Sopenharmony_ciconst { dirname, resolve, relative } = require('path') 41cb0ef41Sopenharmony_ciconst linkBin = isWindows ? require('./shim-bin.js') : require('./link-bin.js') 51cb0ef41Sopenharmony_ciconst normalize = require('npm-normalize-package-bin') 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst linkBins = ({ path, pkg, top, force }) => { 81cb0ef41Sopenharmony_ci pkg = normalize(pkg) 91cb0ef41Sopenharmony_ci if (!pkg.bin) { 101cb0ef41Sopenharmony_ci return Promise.resolve([]) 111cb0ef41Sopenharmony_ci } 121cb0ef41Sopenharmony_ci const promises = [] 131cb0ef41Sopenharmony_ci const target = binTarget({ path, top }) 141cb0ef41Sopenharmony_ci for (const [key, val] of Object.entries(pkg.bin)) { 151cb0ef41Sopenharmony_ci const to = resolve(target, key) 161cb0ef41Sopenharmony_ci const absFrom = resolve(path, val) 171cb0ef41Sopenharmony_ci const from = relative(dirname(to), absFrom) 181cb0ef41Sopenharmony_ci promises.push(linkBin({ path, from, to, absFrom, force })) 191cb0ef41Sopenharmony_ci } 201cb0ef41Sopenharmony_ci return Promise.all(promises) 211cb0ef41Sopenharmony_ci} 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_cimodule.exports = linkBins 24