{"id":17767299,"url":"https://github.com/jamiebuilds/temperment","last_synced_at":"2025-03-15T13:31:14.783Z","repository":{"id":66095032,"uuid":"142201257","full_name":"jamiebuilds/temperment","owner":"jamiebuilds","description":"Get a random temporary file or directory path that will delete itself","archived":false,"fork":false,"pushed_at":"2018-07-24T19:02:08.000Z","size":28,"stargazers_count":22,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-12T21:02:53.098Z","etag":null,"topics":["files","fs","nodejs","temp","tmp"],"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/jamiebuilds.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}},"created_at":"2018-07-24T19:01:20.000Z","updated_at":"2022-02-04T08:36:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"3263cc03-bd85-406f-ba34-e3b26bf9b6e4","html_url":"https://github.com/jamiebuilds/temperment","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"58183a5b25092cac1483f856df8461fb82c8ab55"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiebuilds%2Ftemperment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiebuilds%2Ftemperment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiebuilds%2Ftemperment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamiebuilds%2Ftemperment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamiebuilds","download_url":"https://codeload.github.com/jamiebuilds/temperment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243735840,"owners_count":20339536,"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":["files","fs","nodejs","temp","tmp"],"created_at":"2024-10-26T20:45:56.530Z","updated_at":"2025-03-15T13:31:14.140Z","avatar_url":"https://github.com/jamiebuilds.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# temperment\n\n\u003e Get a random temporary file or directory path that will delete itself\n\n## Install\n\n```sh\nyarn add temperment\n```\n\n## Usage\n\nSame interface as [tempy](https://github.com/sindresorhus/tempy):\n\n```js\nconst temp = require('temperment');\n\ntemp.file(); // \"/private/var/folders/9w/8285f7cn29d74zlvk4b2tclh0000gp/T/679be05150c143aec8c08e35b9f2235a\"\ntemp.file({ name: 'foo' }); // \"/private/var/folders/9w/8285f7cn29d74zlvk4b2tclh0000gp/T/7ee0b6d4d6fbfa9cf644ad367642815a/foo.txt\"\ntemp.file({ extension: 'txt' }); // \"/private/var/folders/9w/8285f7cn29d74zlvk4b2tclh0000gp/T/93b1abc869d30c0ef79c61790d264e6c.txt\"\ntemp.directory(); // \"/private/var/folders/9w/8285f7cn29d74zlvk4b2tclh0000gp/T/a1663ccd3f5b1230e6390f549ed02b24\"\ntemp.root; // \"/private/var/folders/9w/8285f7cn29d74zlvk4b2tclh0000gp/T\"\n```\n\nManually clean files up asynchronously\n\n```js\nconst temp = require('temperment');\nconst fs = require('fs');\nconst pathExists = require('path-exists');\n\nlet fp = temp.file();\npathExists.sync(fp); // false\nfs.writeFileSync(fp, 'hello');\npathExists.sync(fp); // true\n\nawait temp.cleanup();\n\npathExists.sync(dir); // false\n```\n\nManually clean files up synchronously\n\n```js\nconst fs = require('fs');\nconst pathExists = require('path-exists');\n\nconst temp = require('temperment');\n\nlet fp = temp.file();\npathExists.sync(fp); // false\nfs.writeFileSync(fp, 'hello');\npathExists.sync(fp); // true\n\ntemp.cleanup.sync();\n\npathExists.sync(dir); // false\n```\n\nHowever, you don't need to clean files up. This will happen automatically when\nthe process exits (even on errors).\n\nYou can also make a standalone instance of temperment where you won't\naccidentally delete someone else's temp files and they won't accidentally\ndelete yours:\n\n```js\nconst temperment = require('temperment');\nconst temp = temperment.standalone();\n\ntemp.file();\ntemp.directory();\n\nawait temp.cleanup(); // only delete your own files\nawait temperment.cleanup(); // won't delete files created by `temp`\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamiebuilds%2Ftemperment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamiebuilds%2Ftemperment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamiebuilds%2Ftemperment/lists"}