{"id":17118375,"url":"https://github.com/axelpale/node-fsensure","last_synced_at":"2025-03-24T01:44:48.941Z","repository":{"id":11304347,"uuid":"13720606","full_name":"axelpale/node-fsensure","owner":"axelpale","description":"Ensure directories and files exists or are removed in Node.js.","archived":false,"fork":false,"pushed_at":"2013-10-31T21:43:02.000Z","size":116,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-26T21:45:14.141Z","etag":null,"topics":[],"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/axelpale.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}},"created_at":"2013-10-20T14:37:18.000Z","updated_at":"2013-10-31T21:43:07.000Z","dependencies_parsed_at":"2022-07-12T15:04:24.159Z","dependency_job_id":null,"html_url":"https://github.com/axelpale/node-fsensure","commit_stats":null,"previous_names":["doph/node-fsensure"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axelpale%2Fnode-fsensure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axelpale%2Fnode-fsensure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axelpale%2Fnode-fsensure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axelpale%2Fnode-fsensure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axelpale","download_url":"https://codeload.github.com/axelpale/node-fsensure/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245195909,"owners_count":20575936,"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":[],"created_at":"2024-10-14T17:54:27.384Z","updated_at":"2025-03-24T01:44:48.916Z","avatar_url":"https://github.com/axelpale.png","language":"JavaScript","readme":"# fsensure\n\nEnsure directories and files exists or are removed in Node.js.\n\n## Install\n\nUsing [npm](http://npmjs.org):\n\n```\nnpm install fsensure\n```\n\n##Examples\n\nCreate directories recursively like `mkdir -p`:\n\n```js\nvar fsensure = require('fsensure');\n\nfsensure.dir.exists('/tmp/foo/bar/baz', function (err) {\n    if (err) { console.error(err); return; }\n    console.log('/tmp/foo/bar/baz now exists');\n});\n```\n\nMove files around and automatically create the required directories:\n\n```js\nvar fsensure = require('fsensure');\n\nfsensure.file.move('/tmp/info.txt', '/tmp/archive/info.md', function (err) {\n    if (err) { console.error(err); return; }\n    console.log('/tmp/info.txt moved to /tmp/archive/info.md');\n});\n```\n\n## Methods\n\n### dir.exists(path, \\[mode\\], callback)\n\nEnsure that directory exists. If directory does not exist, try to create the directory in path. Understand the path as a path to directory.\n\n### dir.existsSync(path, \\[mode\\])\n\nSync version of fsensure.dir.exists.\n\n### file.move(source, target, callback)\n\nAlias of fsensure.file.rename.\n\n### file.rename(source, target, callback)\n\nFirst ensures that the directories of the target filepath exists, creates the directories then renames the file.\n\n### file.dir.exists(filepath, callback)\n\nEnsures that the directories of filepath exist. Difference to dir.exists is that here filepath is understood as path to a non-directory file.\n\n### file.copy(source, target, callback)\n\nEnsure that target path exists and copy the file.\n\n### file.remove(target, callback)\n\nAlias of fsensure.file.unlink\n\n### file.unlink(target, callback)\n\nEnsure that target file is removed. Remove the file if possible.\n\n## TODO\n\n- more tests\n- more comprehensive documentation\n- file.dir.existsSync\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxelpale%2Fnode-fsensure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxelpale%2Fnode-fsensure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxelpale%2Fnode-fsensure/lists"}