fs-mkdirp-stream

WebJar for fs-mkdirp-stream

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

fs-mkdirp-stream
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

fs-mkdirp-stream
WebJar for fs-mkdirp-stream
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/gulpjs/fs-mkdirp-stream

Download fs-mkdirp-stream

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/fs-mkdirp-stream/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>fs-mkdirp-stream</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/fs-mkdirp-stream/
implementation 'org.webjars.npm:fs-mkdirp-stream:1.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/fs-mkdirp-stream/
implementation ("org.webjars.npm:fs-mkdirp-stream:1.0.0")
'org.webjars.npm:fs-mkdirp-stream:jar:1.0.0'
<dependency org="org.webjars.npm" name="fs-mkdirp-stream" rev="1.0.0">
  <artifact name="fs-mkdirp-stream" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='fs-mkdirp-stream', version='1.0.0')
)
libraryDependencies += "org.webjars.npm" % "fs-mkdirp-stream" % "1.0.0"
[org.webjars.npm/fs-mkdirp-stream "1.0.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : graceful-fs jar [4.1.11,5)
org.webjars.npm : through2 jar [2.0.3,3)

Project Modules

There are no modules declared in this project.

fs-mkdirp-stream

NPM version Downloads Build Status Coveralls Status

Ensure directories exist before writing to them.

Usage

var to = require('to2');
var from = require('from2');
var mkdirpStream = require('fs-mkdirp-stream');

from
  .obj([{ dirname: '/path/to/my/', path: '/path/to/my/file.js' }])
  .pipe(
    mkdirpStream(function (obj, callback) {
      // callback can take 3 arguments (err, dirname, mode)
      callback(null, obj.dirname);
    })
  )
  .pipe(
    to.obj(function (obj) {
      // This will be called once the directory exists
      // obj === { dirname: '/path/to/my/', path: '/path/to/my/file.js' }
    })
  );

API

mkdirpStream(resolver)

Takes a resolver function or string and returns a streamx.Transform stream.

If 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.

If 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.

License

MIT

Contains 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.

org.webjars.npm

gulp

A toolkit to automate & enhance your workflow

Versions

Version
1.0.0