{"id":14982066,"url":"https://github.com/gulpjs/fs-mkdirp-stream","last_synced_at":"2025-10-19T11:31:20.449Z","repository":{"id":20896121,"uuid":"91203746","full_name":"gulpjs/fs-mkdirp-stream","owner":"gulpjs","description":"Ensure directories exist before writing to them.","archived":false,"fork":false,"pushed_at":"2023-04-15T22:04:52.000Z","size":35,"stargazers_count":8,"open_issues_count":1,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-29T15:14:40.349Z","etag":null,"topics":["filesystem","fs","mkdir","mkdirp","node","nodejs","streams"],"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/gulpjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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},"funding":{"github":["gulpjs","phated","yocontra"],"tidelift":"npm/gulp","open_collective":"gulpjs"}},"created_at":"2017-05-13T21:27:25.000Z","updated_at":"2023-11-05T01:08:58.000Z","dependencies_parsed_at":"2022-07-26T12:47:00.842Z","dependency_job_id":"33e5f890-cc09-4085-8090-31b2e1c25015","html_url":"https://github.com/gulpjs/fs-mkdirp-stream","commit_stats":{"total_commits":24,"total_committers":6,"mean_commits":4.0,"dds":0.5,"last_synced_commit":"e62964186099f6a08b9a39b7394ee5e3a6aad1e9"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Ffs-mkdirp-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Ffs-mkdirp-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Ffs-mkdirp-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gulpjs%2Ffs-mkdirp-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gulpjs","download_url":"https://codeload.github.com/gulpjs/fs-mkdirp-stream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237116938,"owners_count":19258331,"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":["filesystem","fs","mkdir","mkdirp","node","nodejs","streams"],"created_at":"2024-09-24T14:04:43.736Z","updated_at":"2025-10-19T11:31:15.419Z","avatar_url":"https://github.com/gulpjs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/gulpjs","https://github.com/sponsors/phated","https://github.com/sponsors/yocontra","https://tidelift.com/funding/github/npm/gulp","https://opencollective.com/gulpjs"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://gulpjs.com\"\u003e\n    \u003cimg height=\"257\" width=\"114\" src=\"https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n# fs-mkdirp-stream\n\n[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]\n\nEnsure directories exist before writing to them.\n\n## Usage\n\n```js\nvar { Readable, Writable } = require('streamx');\nvar mkdirpStream = require('fs-mkdirp-stream');\n\nReadable.from([{ dirname: './path/to/my/', path: './path/to/my/file.js' }])\n  .pipe(\n    mkdirpStream(function (obj, callback) {\n      // callback can take 3 arguments (err, dirname, mode)\n      callback(null, obj.dirname);\n    })\n  )\n  .pipe(\n    new Writable({\n      write: function (obj, cb) {\n        // This will be called once the directory exists\n        // obj === { dirname: '/path/to/my/', path: '/path/to/my/file.js' }\n        cb();\n      },\n    })\n  );\n```\n\n## API\n\n### `mkdirpStream(resolver)`\n\nTakes a `resolver` function or string and returns a `streamx.Transform` stream.\n\nIf the `resolver` is a function, it will be called once per chunk with the signature `(chunk, callback)`. The `callback(error, dirpath, mode)` must be called with the `dirpath` to be created as the 2nd parameter or an `error` as the 1st parameter; optionally with a `mode` as the 3rd parameter.\n\nIf the `resolver` is a string, it will be created/ensured for each chunk (e.g. if it were deleted between chunks, it would be recreated). When using a string, a custom `mode` can't be used.\n\n## License\n\nMIT\n\nContains a custom implementation of `mkdirp` originally based on https://github.com/substack/node-mkdirp (Licensed MIT/X11 - Copyright 2010 James Halliday) with heavy modification to better support custom modes.\n\n\u003c!-- prettier-ignore-start --\u003e\n[downloads-image]: https://img.shields.io/npm/dm/fs-mkdirp-stream.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/fs-mkdirp-stream\n[npm-image]: https://img.shields.io/npm/v/fs-mkdirp-stream.svg?style=flat-square\n\n[ci-url]: https://github.com/gulpjs/fs-mkdirp-stream/actions?query=workflow:dev\n[ci-image]: https://img.shields.io/github/actions/workflow/status/gulpjs/fs-mkdirp-stream/dev.yml?branch=master\u0026style=flat-square\n\n[coveralls-url]: https://coveralls.io/r/gulpjs/fs-mkdirp-stream\n[coveralls-image]: https://img.shields.io/coveralls/gulpjs/fs-mkdirp-stream/master.svg?style=flat-square\n\u003c!-- prettier-ignore-end --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Ffs-mkdirp-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgulpjs%2Ffs-mkdirp-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgulpjs%2Ffs-mkdirp-stream/lists"}