module.exports=fileCompletionvarmkdir=require("mkdirp"),path=require("path"),glob=require("glob")functionfileCompletion(root,req,depth,cb){if(typeofcb!=="function")cb=depth,depth=Infinitymkdir(root,function(er){if(er)returncb(er)// can be either exactly the req, or a descendentvarpattern=root+"/{"+req+","+req+"/**/*}",opts={mark:true,dot:true,maxDepth:depth}glob(pattern,opts,function(er,files){if(er)returncb(er)returncb(null,(files||[]).map(function(f){returnpath.join(req,f.substr(root.length+1).substr((f===req?path.dirname(req):req).length).replace(/^\//,""))}))})})}