-
Notifications
You must be signed in to change notification settings - Fork 30
Replace wrench with node-fs-extra #34
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
Conversation
Can you please update this plugin in npm? https://www.npmjs.com/package/serverless-optimizer-plugin still says v2.1.0 (not 2.1.1) |
wrench.mkdirSyncRecursive(path.dirname(destPath), '0777'); | ||
S.utils.writeFileSync(destPath, S.utils.readFileSync(p)); | ||
fs.mkdirsSync(path.dirname(destPath), '0777'); | ||
fs.copySync(p, destPath, {clobber: true, dereference: true}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the link I posted in the other task, the dereference
option is only supported for the fs-extra.copy
and not the fs-extra.copySync
. I would suggest to use the asynchronous variant here, maybe wrapped by a Promise.fromCallback() to have a promisified implementation.
See also here: jprichardson/node-fs-extra#210
@HyperBrain pretty sure its used in both. EDIT: n/m looks like you are right. Will dig into this more and probably will end up replacing |
@HyperBrain hmm but jprichardson/node-fs-extra#210 indicates that copySync handles symlinks, which is prob why |
This small test confirms that 'use strict';
let fs = require('fs-extra');
fs.copySync('/tmp/tmp1', '/tmp/two', {clobber: true, dereference: true});
fs.copySync('/tmp/tmp1', '/tmp/three', {clobber: true, dereference: true}, function() {
console.log('done');
}); /tmp/tmp1 $ ll
total 12K
drwxr-xr-x 5 ryan wheel 170 Apr 6 16:12 ./
drwxrwxrwt 50 root wheel 1.7K Apr 6 16:11 ../
-rw-r--r-- 1 ryan wheel 3 Apr 6 16:02 hard.txt
lrwxr-xr-x 1 ryan wheel 28 Apr 6 16:07 me.jpg -> /Users/ryan/Dropbox/ryan.jpg
lrwxr-xr-x 1 ryan wheel 28 Apr 6 16:12 symDir -> /Users/ryan/Dropbox/branding/
/tmp/tmp1 $ ll /tmp/two/
total 12K
drwxr-xr-x 5 ryan wheel 170 Apr 6 16:12 ./
drwxrwxrwt 52 root wheel 1.8K Apr 6 16:12 ../
-rw-r--r-- 1 ryan wheel 3 Apr 6 16:12 hard.txt
lrwxr-xr-x 1 ryan wheel 28 Apr 6 16:12 me.jpg -> /Users/ryan/Dropbox/ryan.jpg
lrwxr-xr-x 1 ryan wheel 28 Apr 6 16:12 symDir -> /Users/ryan/Dropbox/branding/
/tmp/tmp1 $ ll /tmp/three
total 12K
drwxr-xr-x 5 ryan wheel 170 Apr 6 16:12 ./
drwxrwxrwt 52 root wheel 1.8K Apr 6 16:12 ../
-rw-r--r-- 1 ryan wheel 3 Apr 6 16:12 hard.txt
lrwxr-xr-x 1 ryan wheel 28 Apr 6 16:12 me.jpg -> /Users/ryan/Dropbox/ryan.jpg
lrwxr-xr-x 1 ryan wheel 28 Apr 6 16:12 symDir -> /Users/ryan/Dropbox/branding/ Or am I missing something? Lastly, do you really want |
is it a typo or did you execute fs.copySync() two times above? |
Nope you are totally correct. I executed My question still stands - why do you want to |
The biggest issue (that initiated the whole deref stuff in SLS) was, that some people have symlinked their node dependencies and it broke as long as the recursive copy did not dereference. |
My guess is they were doing relative symlinks vs full path ones like my example above. If they did full path it would have worked fine. If I go the So how about this, we go with the 80/20 rule thinking that a slim sub-set of people would symlink in the same dir. I'll re-implement with sound ok? |
yes, agree. I event doubt that it's 80/20 but more of a 90/10 :-) |
Addressed in #35 |
Fixes serverless/serverless#952