{"name":"@npmcli/installed-package-contents","version":"5.0.0","author":{"name":"GitHub Inc."},"license":"ISC","_id":"@npmcli/installed-package-contents@5.0.0","maintainers":[{"name":"saquibkhan","email":"saquibkhan@github.com"},{"name":"npm-cli-ops","email":"npm-cli+bot@github.com"},{"name":"reggi","email":"reggi@github.com"},{"name":"owlstronaut","email":"owlstronaut@github.com"}],"homepage":"https://github.com/npm/installed-package-contents#readme","bugs":{"url":"https://github.com/npm/installed-package-contents/issues"},"bin":{"installed-package-contents":"bin/index.js"},"tap":{"nyc-arg":["--exclude","tap-snapshots/**"]},"dist":{"shasum":"3027f15757abbb6286137fe1cf4fc40b387a22a2","tarball":"http://registry-npm.ywwl.com/@npmcli/installed-package-contents/download/@npmcli/installed-package-contents-5.0.0.tgz","fileCount":5,"integrity":"sha512-6Ay12sf2Lh7U1ifvnS1mq7TZFeh/rXHMXye+kV7jQrANIubaoVcleeh4HdFumxhsRYwm9OaHycB5lYmSwGrcIQ==","signatures":[{"sig":"MEUCIQDqB4X7jpMeakEj83Bk8STosF5dfZzcFI5t1sWzUmkObwIgfTCXQAK6nL/Jrydy8O/i+/NGyH89OPhRBJTGyo4MYyY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@npmcli%2finstalled-package-contents@5.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":12361,"size":4878,"noattachment":false,"key":"/@npmcli/installed-package-contents/-/@npmcli/installed-package-contents-5.0.0.tgz"},"main":"lib/index.js","engines":{"node":"^22.22.2 || ^24.15.0 || >=26.0.0"},"gitHead":"1c02318259f89e71a473cf4a93f1ce6e187a7f76","scripts":{"lint":"npm run eslint","snap":"tap","test":"tap","eslint":"eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"","lintfix":"npm run eslint -- --fix","postlint":"template-oss-check","posttest":"npm run lint","template-oss-apply":"template-oss-apply --force"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:8ce01942-62c8-4fd3-896f-650cdb76f1ba"}},"repository":{"url":"git+https://github.com/npm/installed-package-contents.git","type":"git"},"_npmVersion":"11.14.1","description":"Get the list of files installed in a package in node_modules, including bundled dependencies","directories":{},"templateOSS":{"publish":true,"version":"5.1.0","//@npmcli/template-oss":"This file is partially managed by @npmcli/template-oss. Edits may be overwritten."},"_nodeVersion":"26.1.0","dependencies":{"npm-bundled":"^6.0.0","npm-normalize-package-bin":"^6.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^16.3.0","@npmcli/template-oss":"5.1.0","@npmcli/eslint-config":"^6.0.0"},"_npmOperationalInternal":{"tmp":"tmp/installed-package-contents_5.0.0_1779138197572_0.8175948079139719","host":"s3://npm-registry-packages-npm-production"},"readme":"# @npmcli/installed-package-contents\n\nGet the list of files installed in a package in node_modules, including\nbundled dependencies.\n\nThis is useful if you want to remove a package node from the tree _without_\nremoving its child nodes, for example to extract a new version of the\ndependency into place safely.\n\nIt's sort of the reflection of [npm-packlist](http://npm.im/npm-packlist),\nbut for listing out the _installed_ files rather than the files that _will_\nbe installed.  This is of course a much simpler operation, because we don't\nhave to handle ignore files or package.json `files` lists.\n\n## USAGE\n\n```js\n// programmatic usage\nconst pkgContents = require('@npmcli/installed-package-contents')\n\npkgContents({ path: 'node_modules/foo', depth: 1 }).then(files => {\n  // files is an array of items that need to be passed to\n  // rimraf or moved out of the way to make the folder empty\n  // if foo bundled dependencies, those will be included.\n  // It will not traverse into child directories, because we set\n  // depth:1 in the options.\n  // If the folder doesn't exist, this returns an empty array.\n})\n\npkgContents({ path: 'node_modules/foo', depth: Infinity }).then(files => {\n  // setting depth:Infinity tells it to keep walking forever\n  // until it hits something that isn't a directory, so we'll\n  // just get the list of all files, but not their containing\n  // directories.\n})\n```\n\nAs a CLI:\n\n```bash\n$ installed-package-contents node_modules/bundle-some -d1\nnode_modules/.bin/some\nnode_modules/bundle-some/package.json\nnode_modules/bundle-some/node_modules/@scope/baz\nnode_modules/bundle-some/node_modules/.bin/foo\nnode_modules/bundle-some/node_modules/foo\n```\n\nCLI options:\n\n```\nUsage:\n  installed-package-contents <path> [-d<n> --depth=<n>]\n\nLists the files installed for a package specified by <path>.\n\nOptions:\n  -d<n> --depth=<n>   Provide a numeric value (\"Infinity\" is allowed)\n                      to specify how deep in the file tree to traverse.\n                      Default=1\n  -h --help           Show this usage information\n```\n\n## OPTIONS\n\n* `depth` Number, default `1`.  How deep to traverse through folders to get\n    contents.  Typically you'd want to set this to either `1` (to get the\n    surface files and folders) or `Infinity` (to get all files), but any\n    other positive number is supported as well.  If set to `0` or a\n    negative number, returns the path provided and (if it is a package) its\n    set of linked bins.\n* `path` Required.  Path to the package in `node_modules` where traversal\n    should begin.\n\n## RETURN VALUE\n\nA Promise that resolves to an array of fully-resolved files and folders\nmatching the criteria.  This includes all bundled dependencies in\n`node_modules`, and any linked executables in `node_modules/.bin` that the\npackage caused to be installed.\n\nAn empty or missing package folder will return an empty array.  Empty\ndirectories _within_ package contents are listed, even if the `depth`\nargument would cause them to be traversed into.\n\n## CAVEAT\n\nIf using this module to generate a list of files that should be recursively\nremoved to clear away the package, note that this will leave empty\ndirectories behind in certain cases:\n\n- If all child packages are bundled dependencies, then the\n    `node_modules` folder will remain.\n- If all child packages within a given scope were bundled dependencies,\n    then the `node_modules/@scope` folder will remain.\n- If all linked bin scripts were removed, then an empty `node_modules/.bin`\n    folder will remain.\n\nIn the interest of speed and algorithmic complexity, this module does _not_\ndo a subsequent readdir to see if it would remove all directory entries,\nthough it would be easier to look at if it returned `node_modules` or\n`.bin` in that case rather than the contents.  However, if the intent is to\npass these arguments to `rimraf`, it hardly makes sense to do _two_\n`readdir` calls just so that we can have the luxury of having to make a\nthird.\n\nSince the primary use case is to delete a package's contents so that they\ncan be re-filled with a new version of that package, this caveat does not\npose a problem.  Empty directories are already ignored by both npm and git.\n","publish_time":1779138197716,"_cnpm_publish_time":1779138197716,"dist-tags":{"latest":"5.0.0"}}