Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

fs-extra-promise

overlookmotel55.7kMIT1.0.1TypeScript support: definitely-typed

Node file system library and fs-extra module promisified with bluebird

fs, fs-extra, file, promise, bluebird, extend

readme

fs-extra-promise.js

Node file system library and fs-extra module promisified with bluebird

Current status

NPM version Build Status Dependency Status Dev dependency Status Coverage Status

API is stable. No tests at present but it seems to work fine!

Usage

This module is a drop-in replacement for the native node file system module and the augmented fs-extra module.

Additionally, it creates promisified versions of all fs's and fs-extra's async methods, using bluebird. These methods are named the same as the original fs/fs-extra methods with 'Async' added to the end of the method names.

So instead of:

var fs = require('fs');
fs.readFile(path, function(err, data) {
    console.log(data);
});

You can now:

var fs = require('fs-extra-promise');
fs.readFileAsync(path).then(function(data) {
    console.log(data);
});

All original fs and fs-extra methods are included unmodified.

isDirectory() methods

For convenience, additional methods isDirectory(), isDirectorySync() and isDirectoryAsync() are provided.

These are are shortcuts for doing fs.stat() followed by running isDirectory() on the result returned by stat().

usePromise() method

Creates a new instance of fs-extra-promise, which uses the Promise implementation provided.

var Bluebird = require('bluebird');
var fs = require('fs-extra-promise').usePromise(Bluebird);

// now use `fs-extra-promise` in the usual way
var promise = fs.readFileAsync(path);

console.log(promise instanceof Bluebird); // true

This can be useful for:

  • using a different version of bluebird
  • using a Promise implementation that supports cls
  • using an augmented version of Bluebird like bluebird-extra

useFs() method

Creates a new instance of fs-extra-promise, promisifying the provide version of fs-extra.

Most useful if you want to use a specific version of fs-extra.

var fs = require('fs-extra-promise').useFs(require('fs-extra'));

Tests

Use npm test to run the tests. Use npm run cover to check coverage.

There aren't any tests at present, except for running jshint on the code.

Changelog

See changelog.md

Issues

If you discover a bug, please raise an issue on Github. https://github.com/overlookmotel/fs-extra-promise/issues

changelog

Changelog

0.0.1

  • Initial release

0.1.0

  • Expose Promise object so it can be augmented (e.g. by bluebird-extra module)

0.1.1

  • Updated fs-extra dependency to v0.18.2
  • Updated bluebird dependency to v2.9.24
  • Travis runs tests against node 0.10 and 0.12
  • Travis runs on new container infrastructure

0.1.2

  • Update fs-extra dependency
  • Update bluebird dependency
  • Update dev dependencies
  • Run jshint on tests
  • Test code coverage & Travis sends to coveralls
  • README badges use shields.io

0.1.3

  • Disable Travis dependency cache

0.2.0

  • Update fs-extra dependency

0.2.1

  • Update fs-extra dependency
  • Update bluebird dependency
  • Update dev dependencies
  • Change main in package.json to ./lib/index (closes #6)

0.3.0

  • usePromise method
  • Update bluebird dependency
  • Update dev dependencies
  • README update

Breaking changes:

  • Now creates a new instance of fs rather than adding methods to the global fs-extra module

0.3.1

  • Update fs-extra dependency
  • usePromise method anonymous function
  • License update

0.4.0

  • .useFs() method
  • Update fs-extra dependency to v0.30.0
  • Update bluebird dependency to v3.4.0
  • Update dev dependencies
  • Change main in package.json to ./lib/ (closes #7)
  • JSDoc comments
  • README update
  • Replace Makefile with npm scripts
  • Travis tests against node v4 + v6
  • Update .npmignore
  • Update license

0.4.1

  • Update bluebird dependency to v3.4.6
  • Update dev dependencies
  • Ignore .DS_Store in .gitignore
  • Travis CI runs on all branches (to enable greenkeeper.io)

1.0.0

  • Update fs-extra dependency to v2.1.2
  • Update bluebird dependency to v3.5.0
  • Drop support for Node versions before 4.0
  • Fix: Do not promisify createWriteStream method
  • Refactor to ES6 + code style
  • Skip Travis CI runs on release tags
  • Update license

1.0.1

  • Update dev dependencies