Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore existing files? #34

Open
pdehaan opened this issue Oct 14, 2022 · 0 comments
Open

Ignore existing files? #34

pdehaan opened this issue Oct 14, 2022 · 0 comments

Comments

@pdehaan
Copy link

pdehaan commented Oct 14, 2022

I have the following code, but not sure I 100% understand the rules of overwrite:

  copy('assets', 'www/assets', { overwrite: false }, function (err, results) {
    if (err) {
      console.error(`[ERROR] Copy failed: ${err.message}`);
    } else {
      console.info(`Copied ${results.length} files`);
    }
  });

I ran touch assets/{1..1000}.jpg so I have 1001 [invalid] image files locally.
First time I run the code above, everything works and I see this in my console:

Copied 1001 files

Now, if I build my site again and run the same code, I get the following error (since the "www/assets" folder exists and has my previous images):

[ERROR] Copy failed: EEXIST, file already exists www/assets/1000.jpg

If I set { overwrite: true } it works every time, but is presumably recopying over 1001 unchanged files on each build. Is there an option for "copy the image if it doesn't exist, but ignore it if it does"?


UPDATE: I guess I'm asking for a feature/flag similar to merge-dir's conflict resolution of "overwrite"-vs-"skip"-vs-"ask" (but without "ask").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant