"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/which/bin/which" (8 Mar 2017, 985 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env node
    2 var which = require("../")
    3 if (process.argv.length < 3)
    4   usage()
    5 
    6 function usage () {
    7   console.error('usage: which [-as] program ...')
    8   process.exit(1)
    9 }
   10 
   11 var all = false
   12 var silent = false
   13 var dashdash = false
   14 var args = process.argv.slice(2).filter(function (arg) {
   15   if (dashdash || !/^-/.test(arg))
   16     return true
   17 
   18   if (arg === '--') {
   19     dashdash = true
   20     return false
   21   }
   22 
   23   var flags = arg.substr(1).split('')
   24   for (var f = 0; f < flags.length; f++) {
   25     var flag = flags[f]
   26     switch (flag) {
   27       case 's':
   28         silent = true
   29         break
   30       case 'a':
   31         all = true
   32         break
   33       default:
   34         console.error('which: illegal option -- ' + flag)
   35         usage()
   36     }
   37   }
   38   return false
   39 })
   40 
   41 process.exit(args.reduce(function (pv, current) {
   42   try {
   43     var f = which.sync(current, { all: all })
   44     if (all)
   45       f = f.join('\n')
   46     if (!silent)
   47       console.log(f)
   48     return pv;
   49   } catch (e) {
   50     return 1;
   51   }
   52 }, 0))