1

I have below the structure repository:

src
  -common
        - asd.ts
        - filter.ts
  -checking
        -hi.json
  -third-party
        -src
            -common
                   -hello.ts
                   -two.ts  
                   -three.ts

here, i want move files from third-party/src/common to src/common but i have to exlcude three.ts file.

I have treid like below bur it moves all files:

gulp.task('common-update', function (done) {
  shelljs.cp('-rf', './third-party/angularSB/src/app/common/*', './src/app/common/');
  done();
});
Kumaresan Sd
  • 1,399
  • 4
  • 16
  • 34

2 Answers2

1

shelljs's cp function does not have the capability of excluding files when you ask it to copy based on directories or wildcards.

Options to get around this include:

  • Use cp to copy over the collection as you have been and then use rm to delete the specific files you do not want in the destination.
  • Gather a list of files and filter them according to your criteria, then use cp to copy over each file individually.
  • Use a different library, such as copyfiles, that does support some sort of exclude option.
Ouroborus
  • 16,237
  • 4
  • 39
  • 62
1

I have tried like this it works

gulp.task('common-update', function (done) {
  var check = glob.sync('./third-party/src/common/*');
  for (var i = 0; i < check.length - 1; i++) {
    if (check[i].indexOf('three.ts') === -1) {
      shelljs.cp('-rf', check[i], './src/common/');
    }
  }
  done();
});
Kumaresan Sd
  • 1,399
  • 4
  • 16
  • 34