Code Monkey home page Code Monkey logo

Comments (7)

arturadib avatar arturadib commented on May 22, 2024

hey thanks for reporting this -- I've refactored the code, take a look at the source in src/cp.js. if you find the solution please bundle a test in test/cp.js too, thanks again!

from shelljs.

sayedihashimi avatar sayedihashimi commented on May 22, 2024

I think I am running into this issue as well.

from shelljs.

sparkleholic avatar sparkleholic commented on May 22, 2024

Hi @arturadib
How about the following condition ?

$ git diff src/cp.js
diff --git a/src/cp.js b/src/cp.js
index ef19f96..6a0abba 100644
--- a/src/cp.js
+++ b/src/cp.js
@@ -73,6 +73,14 @@ function cpdirSyncRecursive(sourceDir, destDir, opts) {
       cpdirSyncRecursive(srcFile, destFile, opts);
     } else if (srcFileStat.isSymbolicLink()) {
       var symlinkFull = fs.readlinkSync(srcFile);
+      if (fs.existsSync(destFile)) {
+          if (!opts.force) {
+            common.log('skipping existing file: ' + files[i]);
+            return;
+          } else {
+            fs.unlinkSync(destFile);
+          }
+      }
       fs.symlinkSync(symlinkFull, destFile, os.platform() === "win32" ? "junction" : null);
     } else {
       /* At this point, we've hit a file actually worth copying... so copy it on over. */

from shelljs.

sparkleholic avatar sparkleholic commented on May 22, 2024

@arturadib And.. one more question.
I'm looking for the way to copy the real files of symlink links, @eisnerd's PR(eisnerd@2e0ab9d) looks a solution about this.. So, I'm curious if this PR can be applied to the master.

from shelljs.

eisnerd avatar eisnerd commented on May 22, 2024

No PR has been opened including eisnerd@2e0ab9d, but one could be opened for master, i.e., including the commit with the test. I'm not sure this relates to #69. I may have misunderstood #69 as relating to creation of dangling symlinks, which fails in windows, from what I remember.

from shelljs.

sparkleholic avatar sparkleholic commented on May 22, 2024

@arturadib , @eisnerd :
I just made a PR (#164), referred to eisnerd@2e0ab9d and added some condition to delete the existing files for -f option.

from shelljs.

nfischer avatar nfischer commented on May 22, 2024

I think the original issue has since been fixed. I'm going to close this, but I'll open another issue that discusses some of the other issues surrounding symlinks.

from shelljs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.