{"id":21074769,"url":"https://github.com/dawsbot/temp-dir-cp","last_synced_at":"2025-03-14T03:26:31.292Z","repository":{"id":141648048,"uuid":"84408959","full_name":"dawsbot/temp-dir-cp","owner":"dawsbot","description":"⚡️ Copy directories to a unique temp location","archived":false,"fork":false,"pushed_at":"2018-09-04T15:43:09.000Z","size":36,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-06T10:42:00.829Z","etag":null,"topics":["fixtures","testing"],"latest_commit_sha":null,"homepage":"","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/dawsbot.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-09T06:57:45.000Z","updated_at":"2018-09-04T15:43:08.000Z","dependencies_parsed_at":"2023-07-02T17:49:12.251Z","dependency_job_id":null,"html_url":"https://github.com/dawsbot/temp-dir-cp","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Ftemp-dir-cp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Ftemp-dir-cp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Ftemp-dir-cp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Ftemp-dir-cp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dawsbot","download_url":"https://codeload.github.com/dawsbot/temp-dir-cp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243517451,"owners_count":20303631,"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":["fixtures","testing"],"created_at":"2024-11-19T19:17:50.674Z","updated_at":"2025-03-14T03:26:31.262Z","avatar_url":"https://github.com/dawsbot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# temp-dir-cp\n[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![XO code style][xo-image]][xo-url] ![][node-version-image]\n\n\u003e ⚡️ Copy folder to a unique temp location\n\n## Install\n\n```sh\nyarn add temp-dir-cp\n# same as npm install --save\n```\n\n## Usage\n\nAssume that in the current directory, there is a directory called `fixtures`:\n\n```sh\n$ tree\n.\n├── fixtures\n│   └── file.txt\n└── index.js\n```\n\nCall `temp-dir-cp` with `\"fixtures\"`\n\n```js\n// index.js\nconst tempDirCp = require('temp-dir-cp');\n\ntempDirCp('fixtures');\n//=\u003e '/var/folders/6r/cyh35ykj4h77jnn0lz0xqx580000gn/T/87166550876/fixtures'\n\ntempDirCp('fixtures');\n//=\u003e '/var/folders/6r/cyh35ykj4h77jnn0lz0xqx580000gn/T/75704852254/fixtures'\n```\n\nBoth of these newly created directory's have the contents of the `fixtures` directory. Each can be mutated separately without affecting one another or the source.\n\n```sh\n$ tree /var/folders/6r/cyh35ykj4h77jnn0lz0xqx580000gn/T/87166550876\n└── fixtures\n    └── file.txt\n\n$ tree /var/folders/6r/cyh35ykj4h77jnn0lz0xqx580000gn/T/75704852254\n└── fixtures\n    └── file.txt\n```\n\nFor any tests which modify the file-system, you can't `cd` into your fixtures and then run the tests. That would  modify your fixtures and therefore break future tests. Use `tempDirCp` instead and you will have a fresh copy of your files in a unique directory every time. The unique directory is temporary too, so it gets removed on computer startup!\n\n## API\n\n### tempDirCp(sourceDir)\n\n#### Arguments\n\n| Name    | Description                     |   Type   |  Default  |\n| ------- | ------------------------------- | -------- |  -------  |\n| sourceDir  | Directory that should be copied | `string` |   None    |\n\n#### Returns\n\nType: `string`\n\n## License\n\nMIT © [Dawson Botsford](https://dawsonbotsford.com)\n\n[npm-image]: https://badge.fury.io/js/temp-dir-cp.svg\n[npm-url]: https://npmjs.org/package/temp-dir-cp\n[travis-image]: https://travis-ci.org/dawsbot/temp-dir-cp.svg?branch=master\n[travis-url]: https://travis-ci.org/dawsbot/temp-dir-cp\n[xo-image]: https://img.shields.io/badge/code_style-XO-5ed9c7.svg\n[xo-url]: https://github.com/sindresorhus/xo\n[node-version-image]: https://img.shields.io/badge/Node-%3E%3Dv4.0.0-ff69b4.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawsbot%2Ftemp-dir-cp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdawsbot%2Ftemp-dir-cp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawsbot%2Ftemp-dir-cp/lists"}