How to use the appium-support.fs.which function in appium-support

To help you get started, we’ve selected a few appium-support 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 appium / appium-ios-simulator / lib / utils.js View on Github external
async function installSSLCert (pemText, udid) {
  // Check that openssl is installed on the path
  try {
    await fs.which('openssl');
  } catch (e) {
    log.debug(`customSSLCert requires openssl to be available on path`);
    log.errorAndThrow(`Command 'openssl' not found`);
  }

  // Check that sqlite3 is installed on the path
  try {
    await fs.which('sqlite3');
  } catch (e) {
    log.debug(`customSSLCert requires sqlite3 to be available on path`);
    log.errorAndThrow(`Command 'sqlite3' not found`);
  }

  // Create a temporary file to store PEM text
  // (a temp file is necessary to run `openssl` shell commands, can't be done in memory)
  let tempFileName = path.resolve(await tempDir.openDir(), 'temp-ssl-cert.pem');
  let pathToKeychain = new Simulator(udid).getDir();
  await fs.writeFile(tempFileName, pemText);
  try {
    await fs.stat(pathToKeychain);
  } catch (e) {
    log.debug(`Could not install SSL certificate. No simulator with udid '${udid}'`);
    log.errorAndThrow(e);
  }
github appium / appium-ios-simulator / lib / utils.js View on Github external
async function installSSLCert (pemText, udid) {
  // Check that openssl is installed on the path
  try {
    await fs.which('openssl');
  } catch (e) {
    log.debug(`customSSLCert requires openssl to be available on path`);
    log.errorAndThrow(`Command 'openssl' not found`);
  }

  // Check that sqlite3 is installed on the path
  try {
    await fs.which('sqlite3');
  } catch (e) {
    log.debug(`customSSLCert requires sqlite3 to be available on path`);
    log.errorAndThrow(`Command 'sqlite3' not found`);
  }

  // Create a temporary file to store PEM text
  // (a temp file is necessary to run `openssl` shell commands, can't be done in memory)
  let tempFileName = path.resolve(await tempDir.openDir(), 'temp-ssl-cert.pem');
github appium / appium-ios-driver / lib / device-log / ios-log.js View on Github external
async startCaptureRealDevice () {
    let cmd, args, env;
    if ((this.realDeviceLogger || '').indexOf('idevicesyslog') !== -1) {
      logger.debug('Attempting iOS device log capture via libimobiledevice idevicesyslog');
      if (this.realDeviceLogger.toLowerCase() === 'idevicesyslog') {
        cmd = 'idevicesyslog';
        try {
          // make sure it is available on the PATH
          await fs.which('idevicesyslog');
        } catch (err) {
          throw new Error(`Unable to find system idevicesyslog: ${err.message}`);
        }
      } else {
        // make sure the executable exists
        if (!await fs.exists(this.realDeviceLogger)) {
          throw new Error(`Unable to find idevicesyslog from 'realDeviceLogger' capability '${this.realDeviceLogger}'`);
        }
        cmd = this.realDeviceLogger;
      }

      args = ['-u', this.udid];
      env = process.env;
    } else if ((this.realDeviceLogger || '').indexOf('deviceconsole') !== -1) {
      logger.debug('Attempting iOS device log capture via deviceconsole');
      let deviceconsole;
github appium / appium-xcuitest-driver / lib / commands / actions.js View on Github external
async function verifyIFusePresence () {
  if (!await fs.which('ifuse')) {
    log.errorAndThrow(`'ifuse' tool is required to be installed on the machine. ` +
                      `Install it using 'brew cask install osxfuse && brew install ifuse' or check ` +
                      `if it is available in PATH environment variable if the tool is already installed. ` +
                      `Current PATH value: ${process.env.PATH}`);
  }
}
github appium / appium-ios-driver / lib / iwdp.js View on Github external
async isSupported () {
    if (typeof this.supported !== 'undefined') {
      return this.supported;
    }

    try {
      await fs.which(IWDP_CMD);
      this.supported = true;
    } catch (e) {
      this.supported = false;
    }
    return this.supported;
  }
}
github appium / appium-ios-simulator / lib / fbsimctl-utils.js View on Github external
async function assertPresence () {
  try {
    await fs.which(FBSIMCTL);
  } catch (err) {
    throw new Error(`${FBSIMCTL} tool should be present in PATH. ` +
      `Use 'brew tap facebook/fb && brew install fbsimctl --HEAD' command to install it`);
  }
}
github appium / appium-ios-simulator / lib / permissions.js View on Github external
async function execWix (args) {
  try {
    await fs.which(WIX_SIM_UTILS);
  } catch (e) {
    throw new Error(`${WIX_SIM_UTILS} binary has not been found in your PATH. ` +
      `Please install it ('brew tap wix/brew && brew install wix/brew/applesimutils') to ` +
      `be able to change application permissions`);
  }

  log.debug(`Executing: ${WIX_SIM_UTILS} ${quote(args)}`);
  try {
    const {stdout} = await exec(WIX_SIM_UTILS, args);
    log.debug(`Command output: ${stdout}`);
    return stdout;
  } catch (e) {
    throw new Error(`Cannot execute "${WIX_SIM_UTILS} ${quote(args)}". Original error: ${e.stderr || e.message}`);
  }
}