"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/utils/completion/file-completion.js" (11 Apr 2017, 661 Bytes) of package /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 module.exports = fileCompletion
    2 
    3 var mkdir = require('mkdirp')
    4 var glob = require('glob')
    5 
    6 function fileCompletion (root, req, depth, cb) {
    7   if (typeof cb !== 'function') {
    8     cb = depth
    9     depth = Infinity
   10   }
   11   mkdir(root, function (er) {
   12     if (er) return cb(er)
   13 
   14     // can be either exactly the req, or a descendent
   15     var pattern = root + '/{' + req + ',' + req + '/**/*}'
   16     var opts = { mark: true, dot: true, maxDepth: depth }
   17     glob(pattern, opts, function (er, files) {
   18       if (er) return cb(er)
   19       return cb(null, (files || []).map(function (f) {
   20         return f.substr(root.length + 1).replace(/^\/|\/$/g, '')
   21       }))
   22     })
   23   })
   24 }