index.js
function writeStreamToFs(opts, stream) {
    var baseDir = path.join(opts.cwd, opts.directory);
    var walker = walk.walk(baseDir);

    walker.on('errors', function (root, stats, next) {
        stream.emit('error', new PluginError(PLUGIN_NAME, stats.error));
        next();
    });
    walker.on('directory', function (root, stats, next) {
        next();
    });

    walker.on('file', function (root, stats, next) {
        var filePath = path.resolve(root, stats.name);

        fs.readFile(filePath, function (error, data) {
            if (error) {
                stream.emit('error', new PluginError(PLUGIN_NAME, error));
            } else {
                stream.write(new Vinyl({
                    path: path.relative(baseDir, filePath),
                    contents: data
                }));
            }

            next();
        });
    });

    walker.on('end', function () {
        stream.emit('end');
        stream.emit('finish');
    });
}
function writeStreamToFs(opts, stream) {
    var baseDir = path.join(opts.cwd, opts.directory);
    var walker = walk.walk(baseDir);

    walker.on('errors', function (root, stats, next) {
        stream.emit('error', new PluginError(PLUGIN_NAME, stats.error));
        next();
    });
    walker.on('directory', function (root, stats, next) {
        next();
    });

    walker.on('file', function (root, stats, next) {
        var filePath = path.resolve(root, stats.name);

        fs.readFile(filePath, function (error, data) {
            if (error) {
                stream.emit('error', new PluginError(PLUGIN_NAME, error));
            } else {
                stream.write(new Vinyl({
                    path: path.relative(baseDir, filePath),
                    contents: data
                }));
            }

            next();
        });
    });

    walker.on('end', function () {
        stream.emit('end');
        stream.emit('finish');
    });
}
function writeStreamToFs ( opts , stream ) { var baseDir = path . join ( opts . cwd , opts . directory ) ; var walker = walk . walk ( baseDir ) ; walker . on ( 'errors' , function ( root , stats , next ) { stream . emit ( 'error' , new PluginError ( PLUGIN_NAME , stats . error ) ) ; next ( ) ; } ) ; walker . on ( 'directory' , function ( root , stats , next ) { next ( ) ; } ) ; walker . on ( 'file' , function ( root , stats , next ) { var filePath = path . resolve ( root , stats . name ) ; fs . readFile ( filePath , function ( error , data ) { if ( error ) { stream . emit ( 'error' , new PluginError ( PLUGIN_NAME , error ) ) ; } else { stream . write ( new Vinyl ( { path : path . relative ( baseDir , filePath ) , contents : data } ) ) ; } next ( ) ; } ) ; } ) ; walker . on ( 'end' , function ( ) { stream . emit ( 'end' ) ; stream . emit ( 'finish' ) ; } ) ; }
Write stream to filesystem

@param {object} opts options object
@param {object} stream file stream
Write stream to filesystem