Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-webdav-sync

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-webdav-sync

Put files and folders on a WebDAV server. Deploy with gulp

  • 0.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
125
decreased by-33.86%
Maintainers
1
Weekly downloads
 
Created
Source

gulp-webdav-sync

Put files and folders to a WebDAV server. Deploy with gulp.

Usage

URL String

Nominally, pass a URL string.

var webdav = require( 'gulp-webdav-sync' )

// put index.js to http://localhost:8000/js/index.js
gulp.task( 'deploy', function () {
  return gulp.src( 'index.js' )
    .pipe( webdav( 'http://localhost:8000/js/' ) )
} )

URL Object

Extend a URL object.

var webdav = require( 'gulp-webdav-sync' )

// put index.js to http://localhost:8000/js/index.js
// show status codes
// show credentials in urls
gulp.task( 'deploy', function () {
  var options = {
      protocol: 'http:'
    , auth: 'user:pass'
    , hostname: 'localhost'
    , port: 8000
    , pathname: '/js/'
    , log: 'info'
    , logAuth: true
  }
  return gulp.src( 'index.js' )
    .pipe( webdav( options ) )
} )

Subdirectories

Suppose the following directory tree,

  • project/
    • dist/
      • css/
      • images/
      • js/

and this target,

  • localhost:8000/
    • css/
    • images/
    • js/

use the 'parent' option to constrain the localpath mapping,

var webdav = require( 'gulp-webdav-sync' )

gulp.task( 'deploy', function () {
  var options = {
      'log': 'info'
    , 'parent': 'dist'
    , 'port': 8000
  }
  return gulp.src( 'dist/**' )
    .pipe( webdav( options ) )
} )

otherwise, the result is this.

  • localhost:8000/
    • dist/
      • css/
      • images/
      • js/

With gulp.watch

browser-sync, npmconf, and .npmrc for a save-sync-reload solution.

npm set dav http://user:pass@localhost:8000/js/
var browserSync = require( 'browser-sync' ).create()
var webdav = require( 'gulp-webdav-sync' )
var npmconf = require( 'npmconf' )
var paths = {
  'js': [ '*.js', '!gulpfile.js' ]
}
var href
var options = {
  'log': 'info'
}

gulp.task( 'default', [ 'deploy' ], function () {
  browserSync.init( { proxy: href } )
  gulp.watch( paths.js, [ 'deploy' ] )
    .on( 'change', webdav( href, options ).watch )
    .on( 'change', browserSync.reload )
} )

gulp.task( 'deploy', [ 'load-npmrc' ], function () {
  return gulp.src( paths.js )
    .pipe( webdav( href, options ) )
} )

gulp.task( 'load-npmrc', function ( cb ) {
  npmconf.load( null, function() {
    if ( npmconf.loaded.sources.user ) {
      href = npmconf.loaded.sources.user.data.dav
    }
    cb()
  } )
} )

With gulp-watch

gulp-watch re-emits created, modified, and deleted files for upload.

var watch = require( 'gulp-watch' )
var webdav = require( 'gulp-webdav-sync' )
var paths = {
  'js': [ '*.js', '!gulpfile.js' ]
}
var href = 'http://localhost'

gulp.task( 'deploy', function () {
  return gulp.src( paths.js )
    .pipe( watch( paths.js ) )
    .pipe( webdav( href ) )
} )

API

webdav( [ href ] [, options ] )

Target is a URL-type parameter whereto files are uploaded. It must specify a directory ( also known as a "collection" ). At a minimum this must be DAV root, but subdirectories may be included ( e.g. project name ). Part-wise definition across multiple arguments is undefined. Use the http: scheme, not dav:.

webdav( [ href ] [, options ] ).clean( [ cb ] )

Deletes all resources under href.

webdav( [ href ] [, options ] ).watch( event [, cb ] )

Callback adapter for 'change' events from gulp.watch. Only handles type: 'deleted' events. gulp.src does not push deleted files; use this or gulp-watch instead. Calls back regardless of event.type.

event

glob-watcher event.

{
    type: 'deleted'
  , path: '/absolute/path.ext'
}

Type: Object
Default: undefined

cb

Optional, asynchronous, callback function.

Type: Function
Default: undefined

href

Type: String
Default: undefined

options

Superset of http.request options parameter, and url.object. If any URL properties are defined, then protocol, hostname, and pathname are assigned to http://localhost/.

Type: Object
Default:

{
    'agent': false
  , 'clean': false
  , 'log': 'error'
  , 'logAuth': false
  , 'parent': process.cwd()
}

options.clean

Deletes corresponding resources on server instead of uploading. Note, glob star-star will delete directories before contents are pushed.

Type: Boolean
Default: false

options.log

Logging threshold. Orthogonal to the console methods.

stringoutput
'error'
'warn'
'info'HTTP Responses
'log'Debug

Type: String
Default: 'error'

options.logAuth

Display credentials in logged URLs.

Type: Boolean
Default: false

options.parent

Relative or absolute path which halves the source path [vinyl.path] for appending the subsequent to the DAV target URI. Use with glob ** to prevent super-directories from being created on the target. e.g. gulp.src( 'dist/**' ).

Type: String
Default: process.cwd()

Development

cd gulp-webdav-sync
npm install
npm test
npm set dav http://user:pass@localhost:8000/
gulp

Keywords

FAQs

Package last updated on 27 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc