X Tutup
The Wayback Machine - https://web.archive.org/web/20201123155715/https://github.com/shelljs/shelljs/issues/976
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

cp is changing file date with -u option #976

Open
Kwooda opened this issue Nov 5, 2019 · 5 comments
Open

cp is changing file date with -u option #976

Kwooda opened this issue Nov 5, 2019 · 5 comments
Labels

Comments

@Kwooda
Copy link

@Kwooda Kwooda commented Nov 5, 2019

I'm using NodeJS v10.13.0, with shelljs 0.8.3, under Mac OSX 10.13.6, and am performing a copy command, such as:

shell.cp('-RLu', srcDir, targDir);

My understanding is that -u should copy only newer files. But, after a copy, I am seeing the timestamp on the existing files in the target directory are changed to the current time, thus defeating the point of the copy operation to leave existing files unchanged.

@nfischer
Copy link
Member

@nfischer nfischer commented Nov 11, 2019

Looks like a bug. I can repro on my Linux system as well.

Let me know if you're interested in sending a fix.

@nfischer
Copy link
Member

@nfischer nfischer commented Nov 11, 2019

Looks like a bad interaction with passing directories as arguments.

shx cp -RLu srcDir/baz.txt targDir/srcDir/baz.txt # No bug

shx cp -RLu srcDir targDir # This has the bug

This was probably a case I overlooked in the original implementation of the feature.

@Kwooda
Copy link
Author

@Kwooda Kwooda commented Nov 12, 2019

@Kwooda
Copy link
Author

@Kwooda Kwooda commented Dec 11, 2019

Does shelljs support the -p option to preserve timestamp information?

@Kwooda
Copy link
Author

@Kwooda Kwooda commented Jan 8, 2020

shelljs cp command ought to support a -p (preserve) option to preserve timestamps.

Something along the lines of:
var stat = fs.statSync(fromFilePath); fs.utimesSync(toFilePath, stat.atime, stat.mtime)

copyFileSync in cp.js should check for the preserve option and copy the timestamps.

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.
X Tutup