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 - npm Package Compare versions

Comparing version 0.3.6 to 0.4.0

9

gulpfile.js

@@ -19,2 +19,11 @@ var debug = require( 'gulp-debug' )

gulp.task( 'watch', [ '.npmrc' ], function () {
var options = {
'log': 'info'
, 'parent': 'test/assets'
}
gulp.watch( 'test/assets/**', [ 'int-test' ] )
.on( 'change', dav( href, options ).watch )
} )
gulp.task( 'src-test', function () {

@@ -21,0 +30,0 @@ return gulp.src( [ '*.js', 'test/*.js' ] )

85

index.js

@@ -16,3 +16,4 @@ var chalk = require( 'chalk' )

_options = {
'log': 'error'
'agent': false
, 'log': 'error'
, 'logAuth': false

@@ -48,16 +49,22 @@ , 'parent': process.cwd()

}
var href
if ( _string ) {
href = _string
} else {
href = url.format( _options )
}
stream = new Stream.Transform( { objectMode: true } )
stream._transform = function ( vinyl, encoding, callback ) {
const FN_NAME = '#main'
if ( vinyl.event ) {
log.log( _gulp_prefix( FN_NAME + '$vinyl.event' ), vinyl.event )
} else {
vinyl.event = null
}
init()
function init() {
const FN_NAME = 'main#init'
const FN_NAME = '#main#init'
var target_uri
try {
var href
if ( _string ) {
href = _string
} else {
href = url.format( _options )
}
log.log( _gulp_prefix( FN_NAME + '$href' ), href )

@@ -75,3 +82,7 @@ target_uri = _splice_target(

log.log( _gulp_prefix( FN_NAME + '$target_uri' ), target_uri )
_info_target( vinyl, target_uri )
_info_target( vinyl.path, target_uri )
if ( vinyl.event === 'unlink' ) {
_delete( target_uri, resume )
return
}
if ( vinyl.isBuffer() ) {

@@ -94,3 +105,3 @@ _put( target_uri, vinyl, resume )

if ( res ) {
_info_status( res )
_info_status( res.statusCode )
}

@@ -101,2 +112,30 @@ callback()

}
stream.watch = function ( glob_watcher, cb ) {
const FN_NAME = '#watch'
if ( typeof glob_watcher !== 'object'
|| !glob_watcher.type
|| !glob_watcher.path
) {
throw new gutil.PluginError( PLUGIN_NAME, 'expected glob-watcher object' )
}
log.log( _gulp_prefix( FN_NAME + '$arguments[0].path' ), glob_watcher.path )
if ( glob_watcher.type === 'deleted' ) {
var target_uri = _splice_target(
glob_watcher.path
, path.resolve( _options.parent )
, href
)
_info_target( glob_watcher.path, target_uri )
_delete( target_uri, function ( res ) {
_info_status( res.statusCode )
if ( cb && typeof cb === 'function' ) {
cb()
}
} )
} else {
if ( cb && typeof cb === 'function' ) {
cb()
}
}
}
return stream

@@ -140,2 +179,3 @@ }

case 403:
case 404:
case 409:

@@ -166,2 +206,3 @@ case 412:

case 403:
case 404:
case 409:

@@ -182,2 +223,12 @@ case 412:

function _delete( uri, callback ) {
const FN_NAME = '#_delete'
var options, req
options = underscore.extend(
_options
, url.parse( uri )
, { method: 'DELETE' }
)
req = http.request( options, callback )
req.on( 'error', _on_error )
req.end()
}

@@ -195,17 +246,17 @@

function _info_status( res ) {
function _info_status( statusCode ) {
var code =
_colorcode_statusCode_fn( res.statusCode )
.call( this, res.statusCode )
_colorcode_statusCode_fn( statusCode )
.call( this, statusCode )
var msg =
_colorcode_statusMessage_fn( res.statusCode )
.call( this, http.STATUS_CODES[res.statusCode] )
_colorcode_statusMessage_fn( statusCode )
.call( this, http.STATUS_CODES[statusCode] )
log.info( ' ', code, msg )
}
function _info_target( vinyl, uri ) {
function _info_target( vinyl_path, uri ) {
if ( _options.logAuth !== true ) {
uri = _strip_url_auth( uri )
}
var from = chalk.underline.cyan( vinyl.path )
var from = chalk.underline.cyan( vinyl_path )
var to = chalk.underline.cyan( uri )

@@ -212,0 +263,0 @@ log.info( ' ', _align_right( to, from )[1] )

2

package.json
{
"name": "gulp-webdav-sync",
"version": "0.3.6",
"version": "0.4.0",
"description": "Put files and folders on a WebDAV server. Deploy with gulp",

@@ -5,0 +5,0 @@ "repository": {

@@ -81,2 +81,5 @@ # gulp-webdav-sync

var href
var options = {
'log': 'info'
}

@@ -86,2 +89,3 @@ gulp.task( 'default', [ 'deploy' ], function () {

gulp.watch( [ '*.js', '!gulpfile.js' ], [ 'deploy' ] )
.on( 'change', webdav( href, options ).watch )
.on( 'change', browserSync.reload )

@@ -91,5 +95,2 @@ } )

gulp.task( 'deploy', [ 'load-npmrc' ], function () {
var options = {
'log': 'info'
}
return gulp.src( [ '*.js', '!gulpfile.js' ] )

@@ -109,3 +110,3 @@ .pipe( webdav( href, options ) )

With [gulp-watch](https://www.npmjs.com/package/gulp-watch), `gulp deploy` re-emits created and modified files for upload.
With [gulp-watch](https://www.npmjs.com/package/gulp-watch), `gulp deploy` re-emits created, modified, and deleted files for upload.
```js

@@ -131,2 +132,21 @@ var watch = require( 'gulp-watch' )

### 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](https://github.com/floatdrop/gulp-watch) instead. Calls back regardless of `type:`.
#### event
[glob-watcher](https://github.com/wearefractal/glob-watcher/blob/master/index.js#L10) event.
```js
{
type: 'deleted'
, path: '/absolute/path.ext'
}
```
**Type:** `Object`
**Default:** `undefined`
#### cb
Optional asynchronous callback method.
**Type:** `Function`
**Default:** `undefined`
## href

@@ -133,0 +153,0 @@

@@ -255,4 +255,111 @@ var assert = require( 'assert' )

it( 'Should delete a file from a gulp-watch event'
, function ( done ) {
var expected_path = path.join( node, MOCK )
var file = fs.openSync( expected_path, 'w' )
fs.writeSync( file, MOCK )
fs.closeSync( file )
assert( fs.existsSync( expected_path ), 'file exists' )
var options = {
}
var unit = mod( HREF, options )
var mock = new Vinyl( {
path: path.resolve( MOCK )
, contents: new Buffer( MOCK )
} )
mock.event = 'unlink'
unit.write( mock, null, validate )
function validate() {
assert.equal(
fs.existsSync( expected_path )
, false
, 'file exists'
)
done()
}
}
)
it( 'Should delete a directory from a gulp-watch event'
, function ( done ) {
var expected_path = path.join( node, MOCK )
var file = fs.openSync( expected_path, 'w' )
fs.writeSync( file, MOCK )
fs.closeSync( file )
assert( fs.existsSync( expected_path ), 'file exists' )
var options = {
}
var unit = mod( HREF, options )
var mock = new Vinyl( {
path: path.resolve( MOCK )
} )
mock.event = 'unlink'
unit.write( mock, null, validate )
function validate() {
assert.equal(
fs.existsSync( expected_path )
, false
, 'file exists'
)
done()
}
}
)
} )
describe( '#main().watch', function () {
it( 'Should delete a file from a glob-watcher event'
, function ( done ) {
var expected_path = path.join( node, MOCK )
var file = fs.openSync( expected_path, 'w' )
fs.writeSync( file, MOCK )
fs.closeSync( file )
assert( fs.existsSync( expected_path ), 'file exists' )
var options = {
}
var unit = mod( HREF, options )
var glob_watcher = {
type: 'deleted'
, path: path.resolve( MOCK )
}
unit.watch( glob_watcher, validate )
function validate() {
assert.equal(
fs.existsSync( expected_path )
, false
, 'file exists'
)
done()
}
}
)
it( 'Should delete a directory from a glob-watcher event'
, function ( done ) {
var expected_path = path.join( node, MOCK )
fs.mkdirSync( expected_path )
assert( fs.existsSync( expected_path ), 'dir exists' )
var options = {
}
var unit = mod( HREF, options )
var glob_watcher = {
type: 'deleted'
, path: path.resolve( MOCK )
}
unit.watch( glob_watcher, validate )
function validate() {
assert.equal(
fs.existsSync( expected_path )
, false
, 'file exists'
)
done()
}
}
)
} )
} )

Sorry, the diff of this file is not supported yet

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