How to use the which function from shelljs

Find comprehensive JavaScript shelljs.which code examples handpicked from public code repositorys.

1
2
3
4
5
6
7
8
9
10
const path = require('path');
const shell = require('shelljs');
const chalk = require('chalk');

if (shell.which('node')) {
  const NODE_COMMAND_PATH = shell.which('node').stdout;
  const NODE_PATH = path.join(NODE_COMMAND_PATH, '../../lib/node_modules');
  console.log(chalk.yellow('\r\n Please execute flow command, Add global easywebpack-cli to $NODE_PATH'));
  console.log(chalk.green('\r\n1. Use vim command to open bash_profile file: \r\n\r\n') + chalk.blue('vim ~/.bash_profile'));
  console.log(chalk.green('\r\n2. Use export command to add NODE_PATH in bash_profile: \r\n\r\n') + chalk.blue(`export NODE_PATH=${NODE_PATH}:$NODE_PATH`));
fork icon28
star icon123
watch icon9

36
37
38
39
40
41
42
43
44
45
const self = this;
if (!contractFiles || !contractFiles.length) {
  return cb();
}

const vyper = shelljs.which('vyper');
if (!vyper) {
  self.logger.warn(__('%s is not installed on your machine', 'Vyper'));
  self.logger.info(__('You can install it by visiting: %s', 'https://vyper.readthedocs.io/en/latest/installing-vyper.html'));
  return cb();
fork icon533
star icon0
watch icon132

169
170
171
172
173
174
175
176
   * @example
   * // Determine the location of the 'docker' command
   * const which = lando.shell.which(DOCKER_EXECUTABLE);
   */
  which(cmd) {
    return _shell.which(cmd);
  };
};
fork icon13
star icon1
watch icon0

305
306
307
308
309
310
311
312
313
314
315
}
exports.run = run;


var ensureTool = function (name, versionArgs, validate) {
    console.log(name + ' tool:');
    var toolPath = shell.which(name);
    if (!toolPath) {
        fail(name + ' not found.  might need to run npm install');
    }

fork icon0
star icon0
watch icon0