How to use the command-exists.sync function in command-exists

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 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();
github che-incubator / chectl / src / tasks / platforms / microk8s.ts View on Github external
task: () => {
          if (!commandExists.sync('kubectl')) {
            command.error('E_REQUISITE_NOT_FOUND')
          }
        }
      },
github che-incubator / chectl / src / tasks / platforms / crc.ts View on Github external
task: (_ctx: any, task: any) => {
          if (!commandExists.sync('oc')) {
            command.error('E_REQUISITE_NOT_FOUND')
          } else {
            task.title = `${task.title}...done.`
          }
        }
      },
github quanglam2807 / webcatalog / public / libs / is-engine-installed.js View on Github external
}

      if (process.platform === 'linux') {
        return commandExistsSync('chromium-browser');
      }

      return false;
    }
    case 'brave': {
      if (process.platform === 'darwin') {
        const bravePath = path.join('/Applications', 'Brave Browser.app');
        return fs.existsSync(bravePath);
      }

      if (process.platform === 'linux') {
        return commandExistsSync('brave-browser');
      }

      if (process.platform === 'win32') {
        const bravePaths = getWin32BravePaths();
        return bravePaths.length > 0;
      }

      return false;
    }
    case 'vivaldi': {
      if (process.platform === 'darwin') {
        const bravePath = path.join('/Applications', 'Vivaldi.app');
        return fs.existsSync(bravePath);
      }

      if (process.platform === 'linux') {
github popcodeorg / popcode / karma.conf.js View on Github external
webpackMiddleware: {
      logLevel: 'warn',
      stats: 'errors-only',
    },

    reporters: ['dots'],

    port: 9876,

    colors: true,

    logLevel: config.LOG_WARN,

    browsers: [
      commandExists('chromium') ? 'ChromiumHeadless' : 'ChromeHeadless',
    ],

    concurrency: Infinity,

    browserConsoleLogOptions: {
      level: config.LOG_WARN,
    },
  });

  if (browserStackAvailable) {
    const customLaunchers = {};
    allBrowsers.forEach(browser => {
      customLaunchers[`browserStack${browser[0]}${browser[2]}`] = {
        base: 'BrowserStack',
        browser: browser[0],
        browser_version: browser[1],
github kitze / JSUI / electron / electron.js View on Github external
ipc.answerRenderer('command-exists', async command => {
    const result = await sync(command);
    return !!result;
  });

command-exists

check whether a command line command exists in the current environment

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis

Popular command-exists functions