mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 11:36:57 +00:00

PR-URL: https://github.com/nodejs/node/pull/35474 Reviewed-By: Ruy Adorno <ruyadorno@github.com> Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
const linkBins = require('./lib/link-bins.js')
|
|
const linkMans = require('./lib/link-mans.js')
|
|
|
|
const binLinks = opts => {
|
|
const { path, pkg, force, global, top } = opts
|
|
// global top pkgs on windows get bins installed in {prefix}, and no mans
|
|
//
|
|
// unix global top pkgs get their bins installed in {prefix}/bin,
|
|
// and mans in {prefix}/share/man
|
|
//
|
|
// non-top pkgs get their bins installed in {prefix}/node_modules/.bin,
|
|
// and do not install mans
|
|
//
|
|
// non-global top pkgs don't have any bins or mans linked. From here on
|
|
// out, if it's top, we know that it's global, so no need to pass that
|
|
// option further down the stack.
|
|
if (top && !global)
|
|
return Promise.resolve()
|
|
|
|
return Promise.all([
|
|
// allow clobbering within the local node_modules/.bin folder.
|
|
// only global bins are protected in this way, or else it is
|
|
// yet another vector for excessive dependency conflicts.
|
|
linkBins({path, pkg, top, force: force || !top}),
|
|
linkMans({path, pkg, top, force}),
|
|
])
|
|
}
|
|
|
|
const shimBin = require('./lib/shim-bin.js')
|
|
const linkGently = require('./lib/link-gently.js')
|
|
const resetSeen = () => {
|
|
shimBin.resetSeen()
|
|
linkGently.resetSeen()
|
|
}
|
|
|
|
const checkBins = require('./lib/check-bins.js')
|
|
const getPaths = require('./lib/get-paths.js')
|
|
|
|
module.exports = Object.assign(binLinks, {
|
|
checkBins,
|
|
resetSeen,
|
|
getPaths,
|
|
})
|