index.js
function toFiles(app, options) {
  let opts = Object.assign({ collection: null }, options);
  let name = opts.collection;
  let collection = app.collections ? name && app[name] : app;
  let view;

  if (!collection && name) {
    collection = app.create(name, opts);
  }

  return utils.through.obj(async (file, enc, next) => {
    if (!app.File.isFile(file)) {
      file = app.file(file.path, file);
    }

    if (file.isNull()) {
      next(null, file);
      return;
    }

    if (collection && isCollection(collection)) {
      try {
        view = await collection.set(file.path, file);
      } catch (err) {
        next(err);
        return;
      }
      next(null, view);
      return;
    }

    view = !app.File.isFile(file) ? app.file(file.path, file) : file;

    app.handle('onLoad', view)
      .then(() => next(null, view))
      .catch(next);
  });
}
function toFiles(app, options) {
  let opts = Object.assign({ collection: null }, options);
  let name = opts.collection;
  let collection = app.collections ? name && app[name] : app;
  let view;

  if (!collection && name) {
    collection = app.create(name, opts);
  }

  return utils.through.obj(async (file, enc, next) => {
    if (!app.File.isFile(file)) {
      file = app.file(file.path, file);
    }

    if (file.isNull()) {
      next(null, file);
      return;
    }

    if (collection && isCollection(collection)) {
      try {
        view = await collection.set(file.path, file);
      } catch (err) {
        next(err);
        return;
      }
      next(null, view);
      return;
    }

    view = !app.File.isFile(file) ? app.file(file.path, file) : file;

    app.handle('onLoad', view)
      .then(() => next(null, view))
      .catch(next);
  });
}
function toFiles ( app , options ) { let opts = Object . assign ( { collection : null } , options ) ; let name = opts . collection ; let collection = app . collections ? name && app [ name ] : app ; let view ; if ( ! collection && name ) { collection = app . create ( name , opts ) ; } return utils . through . obj ( async ( file , enc , next ) => { if ( ! app . File . isFile ( file ) ) { file = app . file ( file . path , file ) ; } if ( file . isNull ( ) ) { next ( null , file ) ; return ; } if ( collection && isCollection ( collection ) ) { try { view = await collection . set ( file . path , file ) ; } catch ( err ) { next ( err ) ; return ; } next ( null , view ) ; return ; } view = ! app . File . isFile ( file ) ? app . file ( file . path , file ) : file ; app . handle ( 'onLoad' , view ) . then ( ( ) => next ( null , view ) ) . catch ( next ) ; } ) ; }
Make sure vinyl files are assemble files, and add
them to a collection, if specified.
Make sure vinyl files are assemble files and add them to a collection if specified .