{"name":"@npmcli/fs","version":"6.0.0","keywords":["npm","oss"],"author":{"name":"GitHub Inc."},"license":"ISC","_id":"@npmcli/fs@6.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/fs#readme","bugs":{"url":"https://github.com/npm/fs/issues"},"tap":{"nyc-arg":["--exclude","tap-snapshots/**"]},"dist":{"shasum":"a0aa5a02ce8c8c8059d6ca2b8504e2d7adfc1a20","tarball":"http://registry-npm.ywwl.com/@npmcli/fs/download/@npmcli/fs-6.0.0.tgz","fileCount":13,"integrity":"sha512-AheOs4swKka/XLtht6xxJDPezlQ7K2IYQ9Y8lST4JLDjnralnWuMM9AE2CdVcgQJ5omrXhsRzM7F7aYmeZBvKQ==","signatures":[{"sig":"MEYCIQCMp2yc6WQ3KLoXVsik4KympZFbolrVZljHJjtx/arOZwIhAP84xfLXLzj6iQZ59xYNpdwjXkmynHH07szUOBkE9abQ","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@npmcli%2ffs@6.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":26606,"size":8727,"noattachment":false,"key":"/@npmcli/fs/-/@npmcli/fs-6.0.0.tgz"},"main":"lib/index.js","engines":{"node":"^22.22.2 || ^24.15.0 || >=26.0.0"},"gitHead":"790c9dc7b4676a8ca669aa198fa5c745eb310631","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","postsnap":"npm run lintfix --","posttest":"npm run lint","npmclilint":"npmcli-lint","template-oss-apply":"template-oss-apply --force"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:14ad4a25-8ed4-43e9-8236-60894d03026c"}},"repository":{"url":"git+https://github.com/npm/fs.git","type":"git"},"_npmVersion":"11.14.1","description":"filesystem utilities for the npm cli","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":{"semver":"^7.3.5"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^16.0.1","@npmcli/template-oss":"5.1.0","@npmcli/eslint-config":"^6.0.0"},"_npmOperationalInternal":{"tmp":"tmp/fs_6.0.0_1778870659870_0.07330772418051423","host":"s3://npm-registry-packages-npm-production"},"readme":"# @npmcli/fs\n\npolyfills, and extensions, of the core `fs` module.\n\n## Features\n\n- `fs.cp` polyfill for node < 16.7.0\n- `fs.withTempDir` added\n- `fs.readdirScoped` added\n- `fs.moveFile` added\n\n## `fs.withTempDir(root, fn, options) -> Promise`\n\n### Parameters\n\n- `root`: the directory in which to create the temporary directory\n- `fn`: a function that will be called with the path to the temporary directory\n- `options`\n  - `tmpPrefix`: a prefix to be used in the generated directory name\n\n### Usage\n\nThe `withTempDir` function creates a temporary directory, runs the provided\nfunction (`fn`), then removes the temporary directory and resolves or rejects\nbased on the result of `fn`.\n\n```js\nconst fs = require('@npmcli/fs')\nconst os = require('os')\n\n// this function will be called with the full path to the temporary directory\n// it is called with `await` behind the scenes, so can be async if desired.\nconst myFunction = async (tempPath) => {\n  return 'done!'\n}\n\nconst main = async () => {\n  const result = await fs.withTempDir(os.tmpdir(), myFunction)\n  // result === 'done!'\n}\n\nmain()\n```\n\n## `fs.readdirScoped(root) -> Promise`\n\n### Parameters\n\n- `root`: the directory to read\n\n### Usage\n\nLike `fs.readdir` but handling `@org/module` dirs as if they were\na single entry.\n\n```javascript\nconst { readdirScoped } = require('@npmcli/fs')\nconst entries = await readdirScoped('node_modules')\n// entries will be something like: ['a', '@org/foo', '@org/bar']\n```\n\n## `fs.moveFile(source, dest, options) -> Promise`\n\nA fork of [move-file](https://github.com/sindresorhus/move-file) with\nsupport for Common JS.\n\n### Highlights\n\n- Promise API.\n- Supports moving a file across partitions and devices.\n- Optionally prevent overwriting an existing file.\n- Creates non-existent destination directories for you.\n- Automatically recurses when source is a directory.\n\n### Parameters\n\n- `source`: File, or directory, you want to move.\n- `dest`: Where you want the file or directory moved.\n- `options`\n  - `overwrite` (`boolean`, default: `true`): Overwrite existing destination file(s).\n\n### Usage\n\nThe built-in\n[`fs.rename()`](https://nodejs.org/api/fs.html#fs_fs_rename_oldpath_newpath_callback)\nis just a JavaScript wrapper for the C `rename(2)` function, which doesn't\nsupport moving files across partitions or devices. This module is what you\nwould have expected `fs.rename()` to be.\n\n```js\nconst { moveFile } = require('@npmcli/fs');\n\n(async () => {\n\tawait moveFile('source/unicorn.png', 'destination/unicorn.png');\n\tconsole.log('The file has been moved');\n})();\n```\n","publish_time":1778870660011,"_cnpm_publish_time":1778870660011,"dist-tags":{"latest":"6.0.0"}}