{"id":18483314,"url":"https://github.com/cloudcmd/copy-file","last_synced_at":"2025-04-08T18:32:38.071Z","repository":{"id":57102590,"uuid":"131856051","full_name":"cloudcmd/copy-file","owner":"cloudcmd","description":"simply copy a file","archived":false,"fork":false,"pushed_at":"2021-02-10T10:32:50.000Z","size":38,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-08T11:08:36.025Z","etag":null,"topics":["copy","file","javascript","nodejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudcmd.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-02T13:38:56.000Z","updated_at":"2021-02-10T10:32:52.000Z","dependencies_parsed_at":"2022-08-20T22:10:15.193Z","dependency_job_id":null,"html_url":"https://github.com/cloudcmd/copy-file","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudcmd%2Fcopy-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudcmd%2Fcopy-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudcmd%2Fcopy-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudcmd%2Fcopy-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudcmd","download_url":"https://codeload.github.com/cloudcmd/copy-file/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247902534,"owners_count":21015464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["copy","file","javascript","nodejs"],"created_at":"2024-11-06T12:35:16.884Z","updated_at":"2025-04-08T18:32:34.662Z","avatar_url":"https://github.com/cloudcmd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Copy File [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]\n\nSimply copy a file. If an error occurs after the destination file has been opened for writing, `copy-file` will attempt to remove the destination. Correctly copies `symlinks`.\n\n## Install\n\n```\nnpm i @cloudcmd/copy-file\n```\n\n## API\n\n### copyFile(src, dest [, streams])\n\n- `src` `\u003cstring\u003e` - source filename to copy\n- `dest` `\u003cstring\u003e`-  destination filename of the copy operation\n- `streams` `\u003carray\u003e`-  file processing streams (optional)\n\n```js\nconst copyFile = require('@cloudcmd/copy-file');\n\nconst ok = () =\u003e 'ok';\nconst error = (e) =\u003e e.message;\n\ncopyFile('./package.json', './package2.json')\n    .then(ok)\n    .catch(error)\n    .then(console.log);\n```\n\nYou can use preprocessing `streams` of copied file:\n\n```js\nconst copyFile = require('@cloudcmd/copy-file');\n\nconst zlib = require('zlib');\nconst gzip = zlib.createGzip();\n\nconst ok = () =\u003e 'ok';\nconst error = (e) =\u003e e.message;\n\ncopyFile('./package.json', './package2.json', [gzip])\n    .then(ok)\n    .catch(error)\n    .then(console.log);\n```\n\nYou can use `copyFile` with `async-await`:\n\n```js\nconst tryToCatch = require('try-to-catch');\nconst copyFile = require('@cloudcmd/copy-file');\n\n(async () =\u003e {\n    const [e] = await tryToCatch(copyFile, './package.json', './package2.json');\n    \n    if (!e)\n        return;\n    \n    console.error(e.message);\n})();\n```\n\n## Related\n\n- [fs-copy-file](https://github.com/coderaiser/fs-copy-file \"fs-copy-file\") - Node.js `v8.5.0` `fs.copyFile` ponyfill\n- [fs-copy-file-sync](https://github.com/coderaiser/fs-copy-file-sync \"fs-copy-file-sycn\") - Node.js `v8.5.0` `fs.copyFile` ponyfill\n- [copy-symlink](https://github.com/coderaiser/copy-symlink) - Copy symlink because `fs.copyFile` can't.\n\n## License\n\nMIT\n\n[NPMIMGURL]:                https://img.shields.io/npm/v/@cloudcmd/copy-file.svg?style=flat\n[BuildStatusIMGURL]:        https://img.shields.io/travis/cloudcmd/copy-file/master.svg?style=flat\n[DependencyStatusIMGURL]:   https://img.shields.io/david/cloudcmd/copy-file.svg?style=flat\n[LicenseIMGURL]:            https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat\n[CoverageIMGURL]:           https://coveralls.io/repos/cloudcmd/copy-file/badge.svg?branch=master\u0026service=github\n[NPMURL]:                   https://npmjs.org/package/@cloudcmd/copy-file \"npm\"\n[BuildStatusURL]:           https://travis-ci.org/cloudcmd/copy-file  \"Build Status\"\n[DependencyStatusURL]:      https://david-dm.org/cloudcmd/copy-file \"Dependency Status\"\n[LicenseURL]:               https://tldrlegal.com/license/mit-license \"MIT License\"\n[CoverageURL]:              https://coveralls.io/github/cloudcmd/copy-file?branch=master\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudcmd%2Fcopy-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudcmd%2Fcopy-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudcmd%2Fcopy-file/lists"}