11"use strict" ;
2- var path = require ( 'path' ) ,
2+ var webdav = require ( '../lib/index.js' ) ,
3+ path = require ( 'path' ) ,
34 fs = require ( 'fs' )
45
56module . exports = ( callback , options ) => {
@@ -27,6 +28,9 @@ module.exports = (callback, options) => {
2728 {
2829 try
2930 {
31+ if ( fn . constructor !== Function )
32+ throw fn ;
33+
3034 let callback = ( valid , details ) => {
3135 callback = ( valid , details ) => { }
3236
@@ -58,7 +62,11 @@ module.exports = (callback, options) => {
5862 }
5963 }
6064 setTimeout ( ( ) => callback ( false , 'Timeout' ) , options . timeout ) ;
61- fn ( callback )
65+
66+ const server = new webdav . WebDAVServer ( ) ;
67+ server . start ( options . port + this . index , ( ) => {
68+ fn ( callback , server ) ;
69+ } )
6270 }
6371 catch ( ex )
6472 {
@@ -82,14 +90,14 @@ module.exports = (callback, options) => {
8290 f = path . join ( root , f ) ;
8391 try
8492 {
85- require ( f ) ( isValid , options , index ) ;
93+ require ( f ) ( isValid . bind ( { index } ) , options , index ) ;
8694 }
8795 catch ( ex )
8896 {
8997 if ( options . showExceptions )
9098 console . error ( ex ) ;
9199
92- isValid ( f , isValid => isValid ( false , ex ) ) ;
100+ isValid ( f , ex ) ;
93101 }
94102 } )
95103 } )
0 commit comments