PATH:
usr
/
lib
/
node_modules
/
npm
/
node_modules
/
bin-links
/
lib
// we know it's global and/or not top, so the path has to be // {prefix}/node_modules/{name}. Can't rely on pkg.name, because // it might be installed as an alias. const { dirname, basename } = require('path') // this gets called a lot and can't change, so memoize it const memo = new Map() module.exports = path => { if (memo.has(path)) { return memo.get(path) } const scopeOrNm = dirname(path) const nm = basename(scopeOrNm) === 'node_modules' ? scopeOrNm : dirname(scopeOrNm) memo.set(path, nm) return nm }
[-] bin-target.js
[edit]
[-] link-gently.js
[edit]
[+]
..
[-] link-bin.js
[edit]
[-] check-bins.js
[edit]
[-] get-prefix.js
[edit]
[-] fix-bin.js
[edit]
[-] man-target.js
[edit]
[-] is-windows.js
[edit]
[-] shim-bin.js
[edit]
[-] index.js
[edit]
[-] link-bins.js
[edit]
[-] link-mans.js
[edit]
[-] check-bin.js
[edit]
[-] get-node-modules.js
[edit]
[-] get-paths.js
[edit]