{"id":15636333,"url":"https://github.com/saibotsivad/mergefs","last_synced_at":"2026-05-21T23:30:15.029Z","repository":{"id":57294826,"uuid":"297538066","full_name":"saibotsivad/mergefs","owner":"saibotsivad","description":"Like 'Object.assign' but recursive and for files.","archived":false,"fork":false,"pushed_at":"2021-12-09T21:52:54.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-15T10:04:04.679Z","etag":null,"topics":["filepath","files","merge","object-assign"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saibotsivad.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-22T04:47:32.000Z","updated_at":"2020-10-14T13:26:44.000Z","dependencies_parsed_at":"2022-08-29T08:01:53.176Z","dependency_job_id":null,"html_url":"https://github.com/saibotsivad/mergefs","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saibotsivad%2Fmergefs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saibotsivad%2Fmergefs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saibotsivad%2Fmergefs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saibotsivad%2Fmergefs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saibotsivad","download_url":"https://codeload.github.com/saibotsivad/mergefs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240131736,"owners_count":19752727,"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":["filepath","files","merge","object-assign"],"created_at":"2024-10-03T11:02:15.621Z","updated_at":"2026-05-21T23:30:14.975Z","avatar_url":"https://github.com/saibotsivad.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mergefs\n\nLike `Object.assign` but recursive and for files.\n\n## The Idea\n\nSpecify an output folder, and any number of input folders. They will\nbe merged in order to the output, overwriting files duplicated by name.\n\nIn addition, you can also list specific filepaths, in which case *only*\nthose files will be merged from the input folders and written to the\noutput folders.\n\n## The Library\n\nYou can import or require or whatnot the usual ways:\n\n```js\nconst mergefs = require('mergefs')\n// or\nimport { mergefs } from 'mergefs'\n```\n\nThen you call that function, specifying a single output path and an\nordered array of input paths, with an optional list of file paths:\n\n```js\nawait mergefs({\n\t// required\n\toutput: './out',\n\t// required\n\tinput: [\n\t\t'./foo',\n\t\t'./bar',\n\t\t'./bizz'\n\t],\n\t// optional\n\tfiles: [\n\t\t'fizz/buzz.txt'\n\t]\n});\n```\n\nThere is no output from calling this function. If there is an error\nit will be thrown.\n\n## The API\n\n#### `output: String` **required**\n\nThe path to the output folder.\n\nIf the folder doesn't exist, it will be made.\n\n#### `input: Array\u003cString\u003e` **required**\n\nAn *ordered* list of paths to input folders.\n\nThe order matters: the last input will override the first, if\nthere are files with the same name.\n\n#### `files: Array\u003cString\u003e`\n\nAn unordered list of specific file paths to merge.\n\n## The Examples\n\nSuppose you have a folder structure like this:\n\n```\ninput\n  |- 001\n  |  |- aaa\n  |  |  \\- file.txt // \"text-1\"\n  |  \\- bbb\n  |  |  \\- file.txt // \"text-2\"\n  |- 002\n  |  |- aaa\n  |  |  \\- file.txt // \"text-3\"\n  |  \\- ccc\n  |     \\- file.txt // \"text-4\"\n  \\- 003\n     |- bbb\n     |  \\- file.txt // \"text-5\"\n     \\- ccc\n        \\- file.txt // \"text-6\"\n```\n\n#### The Example 1: Merge Everything\n\nIf you wanted to merge all input folders, you would do:\n\n```js\nawait mergefs({\n\toutput: '/output',\n\tinput: [\n\t\t'/input/001',\n\t\t'/input/002',\n\t\t'/input/003'\n\t]\n});\n```\n\nThen the structure of the output folder would be:\n\n```\noutput\n  |- aaa\n  |  \\- file.txt // \"text-3\"\n  |- bbb\n  | \\- file.txt // \"text-5\"\n  \\- ccc\n     \\- file.txt // \"text-6\"\n```\n\n#### The Example 2: Change Merge Order\n\nIf we take the same example but change the order of the input folders:\n\n```js\nawait mergefs({\n\toutput: '/output',\n\tinput: [\n\t\t'/input/003',\n\t\t'/input/002',\n\t\t'/input/001'\n\t]\n});\n```\n\nThen the structure of the output folder would be:\n\n```\noutput\n  |- aaa\n  |  \\- file.txt // \"text-1\"\n  |- bbb\n  | \\- file.txt // \"text-2\"\n  \\- ccc\n     \\- file.txt // \"text-4\"\n```\n\n### The Example 3: Merge Specific Files\n\nIf we take the same input folder structure but list specific files:\n\n```js\nawait mergefs({\n\toutput: '/output',\n\tinput: [\n\t\t'/input/001',\n\t\t'/input/002',\n\t\t'/input/003'\n\t],\n\tfiles: [\n\t\t'ccc/file.txt'\n\t]\n});\n```\n\nThen the structure of the output folder would be:\n\n```\noutput\n  \\- ccc\n     \\- file.txt // \"text-6\"\n```\n\n## The Path Details\n\nBoth the input and output paths will be resolved using the builtin NodeJS\n[`path.resolve`](https://nodejs.org/api/path.html#path_path_resolve_paths).\n\nYou can use relative or absolute paths, and they will be interpreted using\nthat module.\n\nThe `files` properties will be resolved with the input paths using\n[`path.join`](https://nodejs.org/api/path.html#path_path_join_paths)\nand then `path.resolve` on the resulting filepath.\n\n## The License\n\nPublished and released under the\n[Very Open License](http://veryopenlicense.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaibotsivad%2Fmergefs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaibotsivad%2Fmergefs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaibotsivad%2Fmergefs/lists"}