Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function updateProjectFile (agentPath, newBundleId) {
let projectFilePath = `${agentPath}/${PROJECT_FILE}`;
try {
// Assuming projectFilePath is in the correct state, create .old from projectFilePath
await fs.copyFile(projectFilePath, `${projectFilePath}.old`);
await replaceInFile(projectFilePath, new RegExp(WDA_RUNNER_BUNDLE_ID.replace('.', '\.'), 'g'), newBundleId); // eslint-disable-line no-useless-escape
log.debug(`Successfully updated '${projectFilePath}' with bundle id '${newBundleId}'`);
} catch (err) {
log.debug(`Error updating project file: ${err.message}`);
log.warn(`Unable to update project file '${projectFilePath}' with ` +
`bundle id '${newBundleId}'. WebDriverAgent may not start`);
}
}