question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to overwrite artifacts if they exist

See original GitHub issue

Describe your idea

It would be great if we overwrite artifacts such as screenshots or videos by passing through a flag e.g. --overwrite-artifacts.

I’ve managed to get this working locally by adding the following patch to node_modules/detox/src/artifacts/templates/artifact/FileArtifact.js -> moveTemporaryFile method:

diff --git a/node_modules/detox/src/artifacts/templates/artifact/FileArtifact.js b/node_modules/detox/src/artifacts/templates/artifact/FileArtifact.js
index 7f07040..593662d 100644
--- a/node_modules/detox/src/artifacts/templates/artifact/FileArtifact.js
+++ b/node_modules/detox/src/artifacts/templates/artifact/FileArtifact.js
@@ -87,6 +87,12 @@ class FileArtifact extends Artifact {
       return true;
     }
 
+    if (await fs.exists(destination)) {
+      logger.debug({ event: 'MOVE_FILE_OVERWRITE' }, `moving "${source}" to ${destination}`);
+      await fs.move(source, destination, { overwrite: true });
+      return true;
+    }
+
     logger.warn({ event: 'MOVE_FILE_EXISTS' }, `cannot overwrite: "${source}" => "${destination}"`);
     await fs.remove(source);
     return false;

It checks if the file exists at the destination and then passes through the flag option overwrite: true to fs.move

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
noomorphcommented, Apr 13, 2022

Ah, hehe, interesting… I’ll think. 😃

0reactions
stale[bot]commented, Aug 10, 2022

The issue has been closed for inactivity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Overwriting Artifactory artifacts (and history)? - Stack Overflow
The only option that you have will be to remove "Delete/Overwrite" permission to the users. Then, once they will try to write a...
Read more >
[#HAP-208] Build fails on deploy if artifact already exists - JFrog
I believe there should be an option to not fail the build if the user is unable to overwrite a 'release' artifact.
Read more >
Artifacts with the same name from different jobs overwrite each ...
Either a warning should be produced, or the artifacts should be preserved separately - perhaps under a job name.
Read more >
How to avoid overwriting a previous artifact on Artifactory with ...
Hi, I would like to know how avoid the case of you overwrite a artifact published previously by error. Researching on Internet, I...
Read more >
AW: Don't overwrite existing artifact - Apache Mail Archives
Same if I include the build number into the version. ... overwrite of an existing remote artifact, you can use the exists-maven-plugin ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found