vinyl-readfile-promise
v1.0.0
Published
Promise to create a vinyl file object from an actual file
Downloads
3
Maintainers
Readme
vinyl-readfile-promise
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
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.