lib/tools/apks-utils.js
async function extractFromApks (apks, dstPath) {
  if (!_.isArray(dstPath)) {
    dstPath = [dstPath];
  }

  return await APKS_CACHE_GUARD.acquire(apks, async () => {
    // It might be that the original file has been replaced,
    // so we need to keep the hash sums instead of the actual file paths
    // as caching keys
    const apksHash = await fs.hash(apks);
    log.debug(`Calculated '${apks}' hash: ${apksHash}`);

    if (APKS_CACHE.has(apksHash)) {
      const resultPath = path.resolve(APKS_CACHE.get(apksHash), ...dstPath);
      if (await fs.exists(resultPath)) {
        return resultPath;
      }
      APKS_CACHE.del(apksHash);
    }

    const tmpRoot = await tempDir.openDir();
    log.debug(`Unpacking application bundle at '${apks}' to '${tmpRoot}'`);
    await unzipFile(apks, tmpRoot);
    const resultPath = path.resolve(tmpRoot, ...dstPath);
    if (!await fs.exists(resultPath)) {
      throw new Error(`${dstPath.join(path.sep)} cannot be found in '${apks}' bundle. ` +
        `Does the archive contain a valid application bundle?`);
    }
    APKS_CACHE.set(apksHash, tmpRoot);
    return resultPath;
  });
}
async function extractFromApks (apks, dstPath) {
  if (!_.isArray(dstPath)) {
    dstPath = [dstPath];
  }

  return await APKS_CACHE_GUARD.acquire(apks, async () => {
    // It might be that the original file has been replaced,
    // so we need to keep the hash sums instead of the actual file paths
    // as caching keys
    const apksHash = await fs.hash(apks);
    log.debug(`Calculated '${apks}' hash: ${apksHash}`);

    if (APKS_CACHE.has(apksHash)) {
      const resultPath = path.resolve(APKS_CACHE.get(apksHash), ...dstPath);
      if (await fs.exists(resultPath)) {
        return resultPath;
      }
      APKS_CACHE.del(apksHash);
    }

    const tmpRoot = await tempDir.openDir();
    log.debug(`Unpacking application bundle at '${apks}' to '${tmpRoot}'`);
    await unzipFile(apks, tmpRoot);
    const resultPath = path.resolve(tmpRoot, ...dstPath);
    if (!await fs.exists(resultPath)) {
      throw new Error(`${dstPath.join(path.sep)} cannot be found in '${apks}' bundle. ` +
        `Does the archive contain a valid application bundle?`);
    }
    APKS_CACHE.set(apksHash, tmpRoot);
    return resultPath;
  });
}
async function extractFromApks ( apks , dstPath ) { if ( ! _ . isArray ( dstPath ) ) { dstPath = [ dstPath ] ; } return await APKS_CACHE_GUARD . acquire ( apks , async ( ) => { // It might be that the original file has been replaced, // so we need to keep the hash sums instead of the actual file paths // as caching keys const apksHash = await fs . hash ( apks ) ; log . debug ( ` ${ apks } ${ apksHash } ` ) ; if ( APKS_CACHE . has ( apksHash ) ) { const resultPath = path . resolve ( APKS_CACHE . get ( apksHash ) , ... dstPath ) ; if ( await fs . exists ( resultPath ) ) { return resultPath ; } APKS_CACHE . del ( apksHash ) ; } const tmpRoot = await tempDir . openDir ( ) ; log . debug ( ` ${ apks } ${ tmpRoot } ` ) ; await unzipFile ( apks , tmpRoot ) ; const resultPath = path . resolve ( tmpRoot , ... dstPath ) ; if ( ! await fs . exists ( resultPath ) ) { throw new Error ( ` ${ dstPath . join ( path . sep ) } ${ apks } ` + ` ` ) ; } APKS_CACHE . set ( apksHash , tmpRoot ) ; return resultPath ; } ) ; }
Extracts the particular apks package into a temporary folder,
finds and returns the full path to the file contained in this apk.
The resulting temporary path, where the .apks file has been extracted,
will be stored into the internal LRU cache for better performance.

@param {string} apks - The full path to the .apks file
@param {string|Array<String>} dstPath - The relative path to the destination file,
which is going to be extracted, where each path component is an array item
@returns {string} Full path to the extracted file
@throws {Error} If the requested item does not exist in the extracted archive or the provides
apks file is not a valid bundle
Extracts the particular apks package into a temporary folder finds and returns the full path to the file contained in this apk . The resulting temporary path where the . apks file has been extracted will be stored into the internal LRU cache for better performance .