How to use command-exists - 10 common examples

To help you get started, we’ve selected a few command-exists examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github T-Specht / ts-typie / app.js View on Github external
var request = require("request");
var chalk = require("chalk");
var figures = require("figures");
var args = require("args");
var commandExists = require("command-exists");
// list of supported package manager tools
// the first one found will be default
var tools = {
    yarn: { command: 'yarn add -D' },
    npm: { command: 'npm install -D' }
};
// look for the first available tool
var defaultTool;
for (var _i = 0, _a = Object.keys(tools); _i < _a.length; _i++) {
    var tool_1 = _a[_i];
    if (commandExists.sync(tool_1)) {
        defaultTool = tool_1;
        break;
    }
}
if (defaultTool === undefined) {
    console.error('Couldn\'t find a supported package manager tool.');
}
// support for overriding default
args.option('tool', 'Which package manager tool to use', defaultTool);
var opts = args.parse(process.argv, {
    name: 'ts-typie',
    mri: undefined,
    mainColor: 'yellow',
    subColor: 'dim'
});
var tool = tools[opts.tool];
github betaflight / betaflight-configurator / gulpfile.js View on Github external
function release_win(arch, done) {

    // Check if makensis exists
    if (!commandExistsSync('makensis')) {
        console.warn('makensis command not found, not generating win package for ' + arch);
        return done();
    }

    // The makensis does not generate the folder correctly, manually
    createDirIfNotExists(RELEASE_DIR);

    // Parameters passed to the installer script
    const options = {
            verbose: 2,
            define: {
                'VERSION': pkg.version,
                'PLATFORM': arch,
                'DEST_FOLDER': RELEASE_DIR
            }
        }
github paritytech / js-libs / packages / electron / src / getParityPath.ts View on Github external
const isParityInPath = async () => {
  const parityCommandExists = await commandExists('parity');
  if (parityCommandExists) {
    // If yes, return `parity` as command to launch parity
    return 'parity';
  } else {
    throw new Error('Parity not in path.');
  }
};
github kiibohd / configurator / src / renderer / local-storage / dfu-util.js View on Github external
export async function findDfuPath() {
  const win32 = process.platform === 'win32';
  const name = win32 ? 'dfu-util.exe' : 'dfu-util';

  // Prefer the configurator downloaded version (they can always override)
  const localpath = path.join(paths.utils, `dfu-util_v${info.version}`, win32 ? 'dfu-util.exe' : 'dfu-util');
  try {
    await access(localpath);
    return localpath;
  } catch {
    // Just swallow
  }

  try {
    const onPath = await commandExists(name);
    if (onPath) {
      return 'dfu-util';
    }
  } catch {
    // Just swallow
  }

  return '';
}
github paritytech / fether / packages / parity-electron / src / getParityPath.ts View on Github external
const isParityInPath = async () => {
  const parityCommandExists = await commandExists('parity');
  if (parityCommandExists) {
    // If yes, return `parity` as command to launch parity
    return 'parity';
  }
};
github flood-io / element / packages / cli / src / generator / test-env / index.ts View on Github external
installing() {
		const prevValue = process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD
		process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = '1'
		commandExists('yarn', (err: null | Error, exists: boolean) => {
			if (exists) {
				this.yarnInstall()
			} else {
				this.npmInstall()
			}
		})
		process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = prevValue
	}
github satya164 / quik / src / init.js View on Github external
ncp.ncp(path.join(__dirname, '../template/'), dir, err => {
      if (err) {
        reject(err);
        return;
      }

      exists('yarn', (error, status) => {
        if (error) {
          reject(error);
          return;
        }

        try {
          console.log(
            `🍭  Installing ${chalk.bold('react')} and ${chalk.bold(
              'react-dom'
            )}`
          );

          if (status) {
            execSync('yarn add react react-dom', { cwd: dir });
          } else {
            execSync('npm install -S react react-dom', { cwd: dir });
github che-incubator / chectl / src / tasks / platforms / minikube.ts View on Github external
task: () => {
          if (!commandExists.sync('kubectl')) {
            command.error('E_REQUISITE_NOT_FOUND')
          }
        }
      },
github jenkins-x / vscode-jx-tools / src / term / execute.ts View on Github external
function getBinary(): string {
    let jxConfig  = vscode.workspace.getConfiguration("jx", 
        vscode.window.activeTextEditor ? vscode.window.activeTextEditor.document.uri : null);
    var jxPath = '';
    if (jxConfig) {
        jxPath = jxConfig['path'];
    }
    var binary = 'jx';
    var exists = require('command-exists');
    if (jxPath !== null && jxPath !== '' && typeof jxPath !== 'undefined') {
        binary = path.join(jxPath, binary);
        if (!exists.sync(binary)) {
            vscode.window.showErrorMessage('Failed to find the jx binary in your "jx.path" setting.');
            return "";
        }
    } else {
        if (!exists.sync(binary)) {
            vscode.window.showErrorMessage('Failed to find the jx binary in your PATH. You can specify its path in "jx.path" setting')
            return "";
        }
    }
    return binary;
}
github ForbesLindesay / sync-request / index.js View on Github external
function start() {
  if (!spawnSync) {
    throw new Error(
      'Sync-request requires node version 0.12 or later.  If you need to use it with an older version of node\n' +
      'you can `npm install sync-request@2.2.0`, which was the last version to support older versions of node.'
    );
  }
  try {
    if (commandExists.sync('nc')) {
      const findPortResult = spawnSync(process.execPath, [require.resolve('./lib/find-port')]);
      if (findPortResult.status !== 0) {
        throw new Error(
          findPortResult.stderr.toString() ||
          ('find port exited with code ' + findPortResult.status)
        );
      }
      if (findPortResult.error) {
        if (typeof findPortResult.error === 'string') {
          throw new Error(findPortResult.error);
        }
        throw findPortResult.error;
      }
      const ncPort = findPortResult.stdout.toString('utf8').trim();
      const p = spawn(process.execPath, [require.resolve('./lib/nc-server'), ncPort], {stdio: 'inherit'});
      p.unref();

command-exists

check whether a command line command exists in the current environment

MIT
Latest version published 5 years ago

Package Health Score

67 / 100
Full package analysis

Popular command-exists functions