{"_id":"copy-file","_rev":"12-289f9e768c087b201c8d630ebaac6e9b","name":"copy-file","dist-tags":{"latest":"11.1.0"},"versions":{"0.0.1":{"name":"copy-file","version":"0.0.1","author":{"name":"Chris Khoo"},"_id":"copy-file@0.0.1","maintainers":[{"name":"khoomeister","email":"chris.khoo@gmail.com"}],"dist":{"shasum":"a772f8d7eb36c8371513ff80bbaade314129dd59","tarball":"https://registry.npmjs.org/copy-file/-/copy-file-0.0.1.tgz","integrity":"sha512-E2S/iYY3HIC3zevt3zGL/qrhlyhqgdGFEDIh3zyTTslMsI39Ut70yZvPnsYGUeqfhWCzY+X/WvqBnWPxsLtcww==","signatures":[{"sig":"MEYCIQCCoEuJ4/0sLkWSMpCn3vTKNf++ZUkzc15rUVyT5MAtSQIhAMOGsgCvrXJVC9hSTfu5SJ7cZKUgthiplYC28Q4oVDDU","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"src/index.js","readme":"","engines":{"node":">=0.6.18"},"_npmUser":{"name":"khoomeister","email":"chris.khoo@gmail.com"},"licenses":[{"url":"http://opensource.org/licenses/mit-license.php","type":"MIT"}],"_npmVersion":"1.1.21","description":"Copies a file","directories":{},"_nodeVersion":"v0.6.18","dependencies":{},"_defaultsLoaded":true,"devDependencies":{},"_engineSupported":true,"optionalDependencies":{}},"11.0.0":{"name":"copy-file","version":"11.0.0","keywords":["copy","copying","cp","file","clone","fs","stream","file-system","filesystem","ncp","fast","quick","data","content","contents","read","write","io"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"copy-file@11.0.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/copy-file#readme","bugs":{"url":"https://github.com/sindresorhus/copy-file/issues"},"xo":{"rules":{"ava/assertion-arguments":"off"}},"ava":{"serial":true,"workerThreads":false},"dist":{"shasum":"903f0a5a34e5534eaf775352ac9381359c13f258","tarball":"https://registry.npmjs.org/copy-file/-/copy-file-11.0.0.tgz","fileCount":7,"integrity":"sha512-mFsNh/DIANLqFt5VHZoGirdg7bK5+oTWlhnGu6tgRhzBlnEKWaPX2xrFaLltii/6rmhqFMJqffUgknuRdpYlHw==","signatures":[{"sig":"MEUCIQDFneH+E6DmVmuyIP9uoQ40QZlx5XnTsGmdDceXLueQBAIgStPnqO8z09mauPS6e8JgUKUEpi40KilibWpdu5aKK7A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14163},"type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"0ce680c9bd10960b20ae9f6abac71cd85c576dae","scripts":{"test":"xo && nyc ava && tsd"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/copy-file.git","type":"git"},"_npmVersion":"9.2.0","description":"Copy a file","directories":{},"_nodeVersion":"18.18.2","dependencies":{"p-event":"^6.0.0","graceful-fs":"^4.2.11"},"_hasShrinkwrap":false,"devDependencies":{"xo":"^0.56.0","ava":"^5.3.1","del":"^7.1.0","nyc":"^15.1.0","tsd":"^0.29.0","sinon":"^17.0.1","coveralls":"^3.1.1","clear-module":"^4.1.2","import-fresh":"^3.3.0"},"_npmOperationalInternal":{"tmp":"tmp/copy-file_11.0.0_1699170404674_0.6300803525517711","host":"s3://npm-registry-packages"}},"11.1.0":{"name":"copy-file","version":"11.1.0","description":"Copy a file","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/copy-file.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && nyc ava && tsd"},"keywords":["copy","copying","cp","file","clone","fs","stream","file-system","filesystem","ncp","fast","quick","data","content","contents","read","write","io"],"dependencies":{"graceful-fs":"^4.2.11","p-event":"^6.0.0"},"devDependencies":{"ava":"^5.3.1","clear-module":"^4.1.2","coveralls":"^3.1.1","del":"^7.1.0","import-fresh":"^3.3.0","nyc":"^15.1.0","sinon":"^17.0.1","tsd":"^0.29.0","xo":"^0.56.0"},"xo":{"rules":{"ava/assertion-arguments":"off"}},"ava":{"workerThreads":false,"serial":true},"_id":"copy-file@11.1.0","gitHead":"e08be4f61f6e6c015e40aa8fb49e224dcf0a146a","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/copy-file/issues"},"homepage":"https://github.com/sindresorhus/copy-file#readme","_nodeVersion":"20.19.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-X8XDzyvYaA6msMyAM575CUoygY5b44QzLcGRKsK3MFmXcOvQa518dNPLsKYwkYsn72g3EiW+LE0ytd/FlqWmyw==","shasum":"7d2074271b9f032e8be13aa6bae1a2b497a01731","tarball":"https://registry.npmjs.org/copy-file/-/copy-file-11.1.0.tgz","fileCount":7,"unpackedSize":15227,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGnUlxvim9pxavLhXDgI+UBFjj9ptFuiB+kf/h2ZVMpiAiA7p9XJ4RnYB4fRcv8OzTOC0TGL2iwptCf5d83B5S8Avw=="}]},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/copy-file_11.1.0_1755051761331_0.2813916462090704"},"_hasShrinkwrap":false}},"time":{"created":"2012-06-01T12:16:06.474Z","modified":"2025-08-13T02:22:41.720Z","0.0.1":"2012-06-01T12:16:11.448Z","11.0.0":"2023-11-05T07:46:44.904Z","11.1.0":"2025-08-13T02:22:41.548Z"},"bugs":{"url":"https://github.com/sindresorhus/copy-file/issues"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"license":"MIT","homepage":"https://github.com/sindresorhus/copy-file#readme","keywords":["copy","copying","cp","file","clone","fs","stream","file-system","filesystem","ncp","fast","quick","data","content","contents","read","write","io"],"repository":{"type":"git","url":"git+https://github.com/sindresorhus/copy-file.git"},"description":"Copy a file","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"readme":"# copy-file\n\n> Copy a file\n\n## Highlights\n\n- It's super fast by [cloning](https://stackoverflow.com/questions/71629903/node-js-why-we-should-use-copyfile-ficlone-and-copyfile-ficlone-force-what-is) the file whenever possible.\n- Resilient by using [graceful-fs](https://github.com/isaacs/node-graceful-fs).\n- User-friendly by creating non-existent destination directories for you.\n- Can be safe by turning off [overwriting](#overwrite).\n- Preserves file mode [but not ownership](https://github.com/sindresorhus/copy-file/issues/22#issuecomment-502079547).\n- User-friendly errors.\n\n## Install\n\n```sh\nnpm install copy-file\n```\n\n## Usage\n\n```js\nimport {copyFile} from 'copy-file';\n\nawait copyFile('source/unicorn.png', 'destination/unicorn.png');\nconsole.log('File copied');\n```\n\n## API\n\n### copyFile(source, destination, options?)\n\nReturns a `Promise` that resolves when the file is copied.\n\nThe file is cloned if the `onProgress` option is not passed and the [file system supports it](https://stackoverflow.com/a/76496347/64949).\n\n### copyFileSync(source, destination, options?)\n\n#### source\n\nType: `string`\n\nThe file you want to copy.\n\nThe file is cloned if the [file system supports it](https://stackoverflow.com/a/76496347/64949).\n\n#### destination\n\nType: `string`\n\nWhere you want the file copied.\n\n#### options\n\nType: `object`\n\n##### overwrite\n\nType: `boolean`\\\nDefault: `true`\n\nOverwrite existing destination file.\n\n##### cwd\n\nType: `string`\\\nDefault: `process.cwd()`\n\nThe working directory to find source files.\n\nThe source and destination path are relative to this.\n\n##### directoryMode\n\nType: `number`\\\nDefault: `0o777`\n\n[Permissions](https://en.wikipedia.org/wiki/File-system_permissions#Numeric_notation) for created directories.\n\nIt has no effect on Windows.\n\n##### onProgress\n\nType: `(progress: ProgressData) => void`\n\nThe given function is called whenever there is measurable progress.\n\nOnly available when using the async method.\n\n###### `ProgressData`\n\n```js\n{\n\tsourcePath: string,\n\tdestinationPath: string,\n\tsize: number,\n\twrittenBytes: number,\n\tpercent: number\n}\n```\n\n- `sourcePath` and `destinationPath` are absolute paths.\n- `size` and `writtenBytes` are in bytes.\n- `percent` is a value between `0` and `1`.\n\n###### Notes\n\n- For empty files, the `onProgress` callback function is emitted only once.\n\n```js\nimport {copyFile} from 'copy-file';\n\nawait copyFile(source, destination, {\n\tonProgress: progress => {\n\t\t// …\n\t}\n});\n```\n\n## Related\n\n- [cpy](https://github.com/sindresorhus/cpy) - Copy files\n- [cpy-cli](https://github.com/sindresorhus/cpy-cli) - Copy files on the command-line\n- [move-file](https://github.com/sindresorhus/move-file) - Move a file\n- [make-dir](https://github.com/sindresorhus/make-dir) - Make a directory and its parents if needed\n","readmeFilename":"readme.md"}