Thanks to visit codestin.com
Credit goes to github.com

Skip to content

cp -Ru respects the -R but not the -u #808

@jaawerth

Description

@jaawerth

Love the lib - was looking to use this to reduce copy times on builds, but ran into the following:

Node version (or tell us if you're using electron or some other framework):

8.6.0

ShellJS version (the most recent version/Github branch you see the bug on):

shelljs 0.7.8, tested both directly and via shx 0.2.2

Operating system:

Arch Linux (kernel 4.13.12-1)

Description of the bug:

When combining recursive -R and update -u options in both shelljs and shx, "recursive" overrides and ignores "update" - files are recursively copied regardless of whether the src files are newer than dist.

Example ShellJS command to reproduce the error:

Test case (assuming src/static and dist/static have contents)

const shell = require('shelljs');

// overwrite dist/static, verify that all timestamps in dist are now newer than those in src
shell.cp('-R', 'src/static', 'dist/');
console.log(shell.ls('-l', 'src/static').stdout, '\n' + shell.ls('-l', 'dist/static').stdout);
console.log('----------');

setTimeout(() => {
  shell.cp('-Ru', 'src/static/', 'dist/');
  console.log(shell.ls('-l', 'dist/static').stdout);

  // timestamps shouldn't change, but are ~1s newer
}, 1000);

Expected result

Same as

cp -R src/static/ dist/ && ls -l src/static && ls -l dist/static
echo '\n-----\n'
sleep 1
cp -Ru src/static/ dist/ && ls -l dist/static

I think I see where the fix is - just wanted to file this before I forgot in case I don't end up having time in the near future to create a PR.

Metadata

Metadata

Assignees

Labels

fixBug/defect, or a fix for such a problemmedium priority

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions