source: imaps-frontend/node_modules/which/bin/node-which

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100755
File size: 985 bytes
RevLine 
[d565449]1#!/usr/bin/env node
2var which = require("../")
3if (process.argv.length < 3)
4 usage()
5
6function usage () {
7 console.error('usage: which [-as] program ...')
8 process.exit(1)
9}
10
11var all = false
12var silent = false
13var dashdash = false
14var 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
41process.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))
Note: See TracBrowser for help on using the repository browser.