code: async function writeUpdatedPackageFiles(config) {
    logger.trace({ config }, 'writeUpdatedPackageFiles');
    logger.debug('Writing any updated package files');
    if (!config.updatedPackageFiles) {
      logger.debug('No files found');
      return;
    }
    for (const packageFile of config.updatedPackageFiles) {
      if (!packageFile.name.endsWith('package.json')) {
        continue; // eslint-disable-line
      }
      logger.debug(`Writing ${packageFile.name}`);
      const massagedFile = JSON.parse(packageFile.contents);
      if (massagedFile.name) {
        massagedFile.name = massagedFile.name.replace(/[{}]/g, '');
      }
      delete massagedFile.engines;
      delete massagedFile.scripts;
      try {
        const { token } = hostRules.find({ platform: config.platform });
        for (const upgrade of config.upgrades) {
          if (upgrade.gitRef && upgrade.packageFile === packageFile.name) {
            massagedFile[upgrade.depType][upgrade.depName] = massagedFile[
              upgrade.depType
            ][upgrade.depName].replace(
              'git+https://github.com',
              `git+https://${token}@github.com`
            );
          }
        }
      } catch (err) {
        logger.warn({ err }, 'Error adding token to package files');
      }
      await fs.outputFile(
        upath.join(config.localDir, packageFile.name),
        JSON.stringify(massagedFile)
      );
    }
  }
docs: istanbul ignore next