{"id":713,"url":"https://github.com/sindresorhus/make-dir","last_synced_at":"2025-05-14T15:06:42.042Z","repository":{"id":56466150,"uuid":"90776169","full_name":"sindresorhus/make-dir","owner":"sindresorhus","description":"Make a directory and its parents if needed - Think `mkdir -p`","archived":false,"fork":false,"pushed_at":"2024-05-03T07:32:51.000Z","size":56,"stargazers_count":479,"open_issues_count":3,"forks_count":22,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-05-11T19:28:13.334Z","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/sindresorhus.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":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2017-05-09T17:57:35.000Z","updated_at":"2025-05-11T18:18:00.000Z","dependencies_parsed_at":"2024-11-05T18:44:55.291Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/make-dir","commit_stats":{"total_commits":57,"total_committers":12,"mean_commits":4.75,"dds":"0.33333333333333337","last_synced_commit":"783eeb3d37cd2ca4f3751488ddd7a84392637e55"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmake-dir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmake-dir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmake-dir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmake-dir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/make-dir/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253856655,"owners_count":21974581,"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-01-05T20:15:29.449Z","updated_at":"2025-05-14T15:06:42.023Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["目录","JavaScript","Repository","包","Packages","Uncategorized","Filesystem","Libraries"],"sub_categories":["文件系统","Filesystem","Uncategorized"],"readme":"# make-dir\n\n\u003e Make a directory and its parents if needed - Think `mkdir -p`\n\n\u003e [!TIP]\n\u003e You probably want the built-in [`fsPromises.mkdir('…', {recursive: true})`](https://nodejs.org/api/fs.html#fspromisesmkdirpath-options) instead.\n\n### Advantages over `fsPromises.mkdir('…', {recursive: true})`\n\n- Supports a custom `fs` implementation.\n\n### Advantages over [`mkdirp`](https://github.com/isaacs/node-mkdirp)\n\n- Promise API *(Async/await ready!)*\n- Fixes many `mkdirp` issues\n- CI-tested on macOS, Linux, and Windows\n- Actively maintained\n- Doesn't bundle a CLI\n- Uses the native `fs.mkdir/mkdirSync` [`recursive` option](https://nodejs.org/dist/latest/docs/api/fs.html#fs_fs_mkdir_path_options_callback) in Node.js unless [overridden](#fs)\n\n## Install\n\n```sh\nnpm install make-dir\n```\n\n## Usage\n\n```console\n$ pwd\n/Users/sindresorhus/fun\n$ tree\n.\n```\n\n```js\nimport {makeDirectory} from 'make-dir';\n\nconst path = await makeDirectory('unicorn/rainbow/cake');\n\nconsole.log(path);\n//=\u003e '/Users/sindresorhus/fun/unicorn/rainbow/cake'\n```\n\n```console\n$ tree\n.\n└── unicorn\n    └── rainbow\n        └── cake\n```\n\nMultiple directories:\n\n```js\nimport {makeDirectory} from 'make-dir';\n\nconst paths = await Promise.all([\n\tmakeDirectory('unicorn/rainbow'),\n\tmakeDirectory('foo/bar')\n]);\n\nconsole.log(paths);\n/*\n[\n\t'/Users/sindresorhus/fun/unicorn/rainbow',\n\t'/Users/sindresorhus/fun/foo/bar'\n]\n*/\n```\n\n## API\n\n### makeDirectory(path, options?)\n\nReturns a `Promise` for the path to the created directory.\n\n### makeDirectorySync(path, options?)\n\nReturns the path to the created directory.\n\n#### path\n\nType: `string`\n\nThe directory to create.\n\n#### options\n\nType: `object`\n\n##### mode\n\nType: `integer`\\\nDefault: `0o777`\n\nThe directory [permissions](https://x-team.com/blog/file-system-permissions-umask-node-js/).\n\n##### fs\n\nType: `object`\\\nDefault: `import fs from 'node:fs'`\n\nUse a custom `fs` implementation. For example [`graceful-fs`](https://github.com/isaacs/node-graceful-fs).\n\nUsing a custom `fs` implementation will block the use of the native `recursive` option if `fs.mkdir` or `fs.mkdirSync` is not the native function.\n\n## Related\n\n- [make-dir-cli](https://github.com/sindresorhus/make-dir-cli) - CLI for this module\n- [del](https://github.com/sindresorhus/del) - Delete files and directories\n- [globby](https://github.com/sindresorhus/globby) - User-friendly glob matching\n- [cpy](https://github.com/sindresorhus/cpy) - Copy files\n- [cpy-cli](https://github.com/sindresorhus/cpy-cli) - Copy files on the command-line\n- [move-file](https://github.com/sindresorhus/move-file) - Move a file\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fmake-dir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fmake-dir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fmake-dir/lists"}