Sha256: 7c37493fcac8af6526f51f4d83606a733ca7ca3c7b943d1e9239bb30346b019d

Contents?: true

Size: 960 Bytes

Versions: 111

Compression:

Stored size: 960 Bytes

Contents

#!/usr/bin/env node

const which = require('../lib')
const argv = process.argv.slice(2)

const usage = (err) => {
  if (err) {
    console.error(`which: ${err}`)
  }
  console.error('usage: which [-as] program ...')
  process.exit(1)
}

if (!argv.length) {
  return usage()
}

let dashdash = false
const [commands, flags] = argv.reduce((acc, arg) => {
  if (dashdash || arg === '--') {
    dashdash = true
    return acc
  }

  if (!/^-/.test(arg)) {
    acc[0].push(arg)
    return acc
  }

  for (const flag of arg.slice(1).split('')) {
    if (flag === 's') {
      acc[1].silent = true
    } else if (flag === 'a') {
      acc[1].all = true
    } else {
      usage(`illegal option -- ${flag}`)
    }
  }

  return acc
}, [[], {}])

for (const command of commands) {
  try {
    const res = which.sync(command, { all: flags.all })
    if (!flags.silent) {
      console.log([].concat(res).join('\n'))
    }
  } catch (err) {
    process.exitCode = 1
  }
}

Version data entries

111 entries across 36 versions & 2 rubygems

Version Path
rapid_stack-0.2.0 templates/frontend/node_modules/@npmcli/promise-spawn/node_modules/which/bin/which.js
rapid_stack-0.2.0 templates/frontend/node_modules/@npmcli/git/node_modules/which/bin/which.js
rapid_stack-0.2.0 templates/frontend/node_modules/@npmcli/run-script/node_modules/which/bin/which.js
rapid_stack-0.2.0 templates/frontend/node_modules/node-gyp/node_modules/which/bin/which.js
rapid_stack-0.1.1 templates/FrontEnd/node_modules/node-gyp/node_modules/which/bin/which.js
rapid_stack-0.1.1 templates/FrontEnd/node_modules/@npmcli/promise-spawn/node_modules/which/bin/which.js
rapid_stack-0.1.1 templates/FrontEnd/node_modules/@npmcli/run-script/node_modules/which/bin/which.js
rapid_stack-0.1.1 templates/FrontEnd/node_modules/@npmcli/git/node_modules/which/bin/which.js
rapid_stack-0.1.0 templates/FrontEnd/node_modules/@npmcli/run-script/node_modules/which/bin/which.js
rapid_stack-0.1.0 templates/FrontEnd/node_modules/node-gyp/node_modules/which/bin/which.js
rapid_stack-0.1.0 templates/FrontEnd/node_modules/@npmcli/promise-spawn/node_modules/which/bin/which.js
rapid_stack-0.1.0 templates/FrontEnd/node_modules/@npmcli/git/node_modules/which/bin/which.js
immosquare-cleaner-0.1.60 node_modules/@npmcli/git/node_modules/which/bin/which.js
immosquare-cleaner-0.1.60 node_modules/@npmcli/run-script/node_modules/which/bin/which.js
immosquare-cleaner-0.1.60 node_modules/@npmcli/promise-spawn/node_modules/which/bin/which.js
immosquare-cleaner-0.1.59 node_modules/@npmcli/git/node_modules/which/bin/which.js
immosquare-cleaner-0.1.59 node_modules/@npmcli/promise-spawn/node_modules/which/bin/which.js
immosquare-cleaner-0.1.59 node_modules/@npmcli/run-script/node_modules/which/bin/which.js
immosquare-cleaner-0.1.58 node_modules/@npmcli/git/node_modules/which/bin/which.js
immosquare-cleaner-0.1.58 node_modules/@npmcli/promise-spawn/node_modules/which/bin/which.js