1const { readdirScoped } = require('@npmcli/fs') 2 3const installedShallow = async (npm, opts) => { 4 const names = async global => { 5 const paths = await readdirScoped(global ? npm.globalDir : npm.localDir) 6 return paths.map(p => p.replace(/\\/g, '/')) 7 } 8 const { conf: { argv: { remain } } } = opts 9 if (remain.length > 3) { 10 return null 11 } 12 13 const { global } = npm.flatOptions 14 const locals = global ? [] : await names(false) 15 const globals = (await names(true)).map(n => global ? n : `${n} -g`) 16 return [...locals, ...globals] 17} 18 19module.exports = installedShallow 20