How to use the appium-support.fs.copyFile 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-xcuitest-driver / lib / wda / utils.js View on Github external
// Next try Platform path, for earlier Xcode versions
  const platformBased = [
    path.resolve(bootstrapPath, `${deviceInfo.udid}_${deviceInfo.platformVersion}.xctestrun`),
    deviceInfo.platformVersion,
  ];

  for (const [filePath, version] of [sdkBased, platformBased]) {
    if (await fs.exists(filePath)) {
      log.info(`Using '${filePath}' as xctestrun file`);
      return filePath;
    }
    const originalXctestrunFile = path.resolve(bootstrapPath, getXctestrunFileName(deviceInfo, version));
    if (await fs.exists(originalXctestrunFile)) {
      // If this is first time run for given device, then first generate xctestrun file for device.
      // We need to have a xctestrun file **per device** because we cant not have same wda port for all devices.
      await fs.copyFile(originalXctestrunFile, filePath);
      log.info(`Using '${filePath}' as xctestrun file copied by '${originalXctestrunFile}'`);
      return filePath;
    }
  }

  log.errorAndThrow(`If you are using 'useXctestrunFile' capability then you ` +
                                  `need to have a xctestrun file (expected: ` +
                                  `'${path.resolve(bootstrapPath, getXctestrunFileName(deviceInfo, sdkVersion))}')`);
}
github appium / appium-ios-driver / test / unit / ios-log-specs.js View on Github external
beforeEach(async function () {
    // get the simulator, and stub what will be called
    sim = {
      udid: 'fake-udid',
      getLogDir: () => {},
      getPlatformVersion: () => {}
    };
    sinon.stub(sim, 'getLogDir').returns(LOG_DIR);
    sinon.stub(sim, 'getPlatformVersion').returns('8.4');

    // copy the file into a temporary location, so we can muck with it
    let fixSystemLog = path.resolve(LOG_DIR, 'system.log.fixture');
    tmpSystemLog = path.resolve(LOG_DIR, 'system.log');
    await fs.copyFile(fixSystemLog, tmpSystemLog);
  });
  afterEach(async function () {
github appium / appium-adb / lib / tools / android-manifest.js View on Github external
manifestMethods.insertManifest = async function insertManifest (manifest, srcApk, dstApk) {
  log.debug(`Inserting manifest '${manifest}', src: '${srcApk}', dst: '${dstApk}'`);
  await zip.assertValidZip(srcApk);
  await unzipFile(`${manifest}.apk`);
  const manifestName = path.basename(manifest);
  try {
    await this.initAapt();
    await fs.copyFile(srcApk, dstApk);
    log.debug('Moving manifest');
    try {
      await exec(this.binaries.aapt, [
        'remove', dstApk, manifestName
      ]);
    } catch (ign) {}
    await exec(this.binaries.aapt, [
      'add', dstApk, manifestName
    ], {cwd: path.dirname(manifest)});
  } catch (e) {
    log.debug('Cannot insert manifest using aapt. Defaulting to zip. ' +
      `Original error: ${e.stderr || e.message}`);
    const tmpRoot = await tempDir.openDir();
    try {
      // Unfortunately NodeJS does not provide any reliable methods
      // to replace files inside zip archives without loading the
github appium / appium-ios-simulator / test / unit / settings-specs.js View on Github external
beforeEach(async function () {
      let temp = await tempDir.path();
      tmpPlist = path.resolve(temp, 'sample.plist');
      await fs.copyFile(plist, tmpPlist);
    });
github appium / appium-ios-simulator / test / unit / settings-specs.js View on Github external
beforeEach(async function () {
      await fs.copyFile(globalPlistFixtureFile, globalPlistFile);
    });
    afterEach(async function () {
github appium / appium-ios-driver / lib / driver.js View on Github external
async onInstrumentsLaunch () {
    logger.debug('Instruments launched. Starting poll loop for new commands.');
    if (this.opts.origAppPath) {
      logger.debug('Copying app back to its original place');
      return await fs.copyFile(this.opts.app, this.opts.origAppPath);
    }
  }
github appium / appium-uiautomator2-driver / lib / uiautomator2.js View on Github external
const packageInfosMapper = async ({appPath, appId}) => {
      if (await helpers.isWriteable(appPath)) {
        return { appPath, appId };
      }

      log.info(`Server package at '${appPath}' is not writeable. ` +
        `Will copy it into the temporary location at '${tmpRoot}' as a workaround. ` +
        `Consider making this file writeable manually in order to improve the performance of session startup.`);
      const dstPath = path.resolve(tmpRoot, path.basename(appPath));
      await fs.copyFile(appPath, dstPath);
      return {
        appPath: dstPath,
        appId,
      };
    };
github appium / appium-ios-simulator / lib / simulator-xcode-6.js View on Github external
async moveBuiltInApp (appName, appPath, newAppPath) {
    await safeRimRaf(newAppPath);
    await fs.copyFile(appPath, newAppPath);
    log.debug(`Copied '${appName}' to '${newAppPath}'`);

    await fs.rimraf(appPath);
    log.debug(`Temporarily deleted original app at '${appPath}'`);

    return [newAppPath, appPath];
  }