vinyl-readfile-promise

1.0.0 • Public • Published

vinyl-readfile-promise

NPM version Build Status Build status Coverage Status Dependency Status devDependency Status

Promises/A+ version of vinyl-file:

Create a vinyl file from an actual file

var vinylReadFile = require('vinyl-readfile-promise');

vinylReadFile('index.js')
.then(function(file) {
  file.path; //=> /root/dir/index.js
  file.cwd; //=> /root/dir
})
.catch(), function(err) {
  throw err;
});

Installation

Use npm.

npm install vinyl-readfile-promise

API

var vinylReadFile = require('vinyl-readfile-promise');

vinylReadFile(filePath [, options])

filePath: String
options: Object (directly passed to vinyl-file options)
Return: Object (Promise)

When it finish reading a file, it will be fulfilled with a vinyl file object as an argument.

When it fails to read a file, it will be rejected with an error as an argument.

var vinylReadFile = require('vinyl-readfile-promise');

function onFulFilled(file) {
  file.isNull(); //=> false
  file.isBuffer(); //=> false
  file.isBuffer(); //=> true
}

function onRejected(err) {
  throw err;
}

vinylReadFile('path/to/file', {buffer: false}).then(onFulFilled, onRejected);

License

Copyright (c) Shinnosuke Watanabe

Licensed under the MIT License.

Package Sidebar

Install

npm i vinyl-readfile-promise

Weekly Downloads

2

Version

1.0.0

License

none

Last publish

Collaborators

  • shinnn