1.0.14 • Published 9 years ago

mkdir-bluebird v1.0.14

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

mkdir-bluebird

NPM version Build Status Coverage Status Dependency Status NSP Status

promise wrapper for node’s fs.mkdir() that ignores EEXIST by default.

wraps node’s fs.mkdir(), in a bluebird promise that resolves with true if successful or rejects with the Error returned by fs.mkdir(); both results need to be handled by the code calling this function.

table of contents

installation

npm install mkdir-bluebird

usage

mkdir( path, mode )

@param {string|buffer} path
@param {number} [mode = 0o777]
@param {boolean} [ignore = true] ignore `EEXIST` directory errors returned by `fs.mkdir()`
@returns {Promise}

default

ignores EEXIST directory errors returned by fs.mkdir()

var mkdir = require( 'mkdir-bluebird' );

mkdir( 'test-dir' )
  .then(
    /**
     * @param {boolean} result
     */
    function( result ) {
      // handle success
    }
  )
  .catch(
    /**
     * @param {Error} err
     */
    function( err ) {
      // handle error
    }
  );

set ignore to false

acknowledges EEXIST directory errors returned by fs.mkdir()

var mkdir = require( 'mkdir-bluebird' );

mkdir( 'test-dir', null, false )
  .then(
    /**
     * @param {boolean} result
     */
    function( result ) {
      // handle success
    }
  )
  .catch(
    /**
     * @param {Error} err
     */
    function( err ) {
      // handle error
    }
  );

using node’s path module

the path __dirname/test must exist in order to create the directory test-dir in it

var mkdir = require( 'mkdir-bluebird' );
var path = require( 'path' );
var dirpath = path.join( __dirname, 'test', 'test-dir' );

mkdir( dirpath )
  .then(
    /**
     * @param {boolean} result
     */
    function( result ) {
      // handle success
    }
  )
  .catch(
    /**
     * @param {Error} err
     */
    function( err ) {
      // handle error
    }
  );

license

MIT License

1.0.14

9 years ago

1.0.13

9 years ago

1.0.12

9 years ago

1.0.11

9 years ago

1.0.10

9 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago