How can I duplicate a folder structure multiple times using grunt / grunt-contrib-copy

48 Views Asked by At

I have a folder structure that i need to duplicate with custom names to start a project - I've looked at modifying grunt-contrib-copy with a custom function:

  var gruntCopy = grunt.config.get('copy');
  for (var item in gruntCopy) {
      var files = gruntCopy[item].files;
      for (var i = files.length - 1; i >= 0; i--) {
          var fileItem = files[i];
          if (fileItem.dest instanceof Array) {
              files.splice(i, 1);
              for (var j = 0; j < fileItem.dest.length; j++) {
                  files.push({src: fileItem.src, dest: 
                  fileItem.dest[j]})
              }
          }
      }
  }
  grunt.config.set('copy', gruntCopy);

but this is only generating text files with the names from my array rather than copying the folder and it's contents multiple times.

Can anyone show me where I'm going wrong with this?

1

There are 1 best solutions below

0
Christopher Camplin On

I ended up using fs-extra to duplicate directories in case anyone had the same problem.