index.js
function pushCouchapp(dbName, opts) {
  opts = opts || {}

  if (!dbName && typeof dbName !== 'string') {
    throw new PluginError(PLUGIN_NAME, 'Missing database name.');
  }

  return through.obj(function (file, enc, cb) {
    var ddocObj = require(file.path)
    var url = /^https?:\/\//.test(dbName) ? dbName : buildURL(dbName, opts);

    if (file.isNull()) {
      return cb(null, file)
    }

    if (file.isStream()) {
      this.emit('error', new PluginError(PLUGIN_NAME, 'Streaming not supported.'))
      return cb(null, file)
    }

    if (path.extname(file.path) !== '.js') {
      this.emit('error', new PluginError(PLUGIN_NAME, 'File extension not supported.'))
      return cb(null, file)
    }

    if (has(opts, 'attachments')) {
      var attachmentsPath = path.join(process.cwd(), path.normalize(opts.attachments))
      couchapp.loadAttachments(ddocObj, attachmentsPath)
    }

    couchapp.createApp(ddocObj, url, function (app) {
      app.push(function () {
        gutil.log(PLUGIN_NAME, 'Couchapp pushed!')
        return cb(null, file)
      })
    })
  })
}
function pushCouchapp(dbName, opts) {
  opts = opts || {}

  if (!dbName && typeof dbName !== 'string') {
    throw new PluginError(PLUGIN_NAME, 'Missing database name.');
  }

  return through.obj(function (file, enc, cb) {
    var ddocObj = require(file.path)
    var url = /^https?:\/\//.test(dbName) ? dbName : buildURL(dbName, opts);

    if (file.isNull()) {
      return cb(null, file)
    }

    if (file.isStream()) {
      this.emit('error', new PluginError(PLUGIN_NAME, 'Streaming not supported.'))
      return cb(null, file)
    }

    if (path.extname(file.path) !== '.js') {
      this.emit('error', new PluginError(PLUGIN_NAME, 'File extension not supported.'))
      return cb(null, file)
    }

    if (has(opts, 'attachments')) {
      var attachmentsPath = path.join(process.cwd(), path.normalize(opts.attachments))
      couchapp.loadAttachments(ddocObj, attachmentsPath)
    }

    couchapp.createApp(ddocObj, url, function (app) {
      app.push(function () {
        gutil.log(PLUGIN_NAME, 'Couchapp pushed!')
        return cb(null, file)
      })
    })
  })
}
function pushCouchapp ( dbName , opts ) { opts = opts || { } if ( ! dbName && typeof dbName !== 'string' ) { throw new PluginError ( PLUGIN_NAME , 'Missing database name.' ) ; } return through . obj ( function ( file , enc , cb ) { var ddocObj = require ( file . path ) var url = / ^https?:\/\/ / . test ( dbName ) ? dbName : buildURL ( dbName , opts ) ; if ( file . isNull ( ) ) { return cb ( null , file ) } if ( file . isStream ( ) ) { this . emit ( 'error' , new PluginError ( PLUGIN_NAME , 'Streaming not supported.' ) ) return cb ( null , file ) } if ( path . extname ( file . path ) !== '.js' ) { this . emit ( 'error' , new PluginError ( PLUGIN_NAME , 'File extension not supported.' ) ) return cb ( null , file ) } if ( has ( opts , 'attachments' ) ) { var attachmentsPath = path . join ( process . cwd ( ) , path . normalize ( opts . attachments ) ) couchapp . loadAttachments ( ddocObj , attachmentsPath ) } couchapp . createApp ( ddocObj , url , function ( app ) { app . push ( function ( ) { gutil . log ( PLUGIN_NAME , 'Couchapp pushed!' ) return cb ( null , file ) } ) } ) } ) }
Push a CouchApp to a CouchDB database.

@param  {String} db
@param  {Object} opts
@return {Stream}
Push a CouchApp to a CouchDB database .