【问题标题】:How can I duplicate a folder structure multiple times using grunt / grunt-contrib-copy如何使用 grunt / grunt-contrib-copy 多次复制文件夹结构
【发布时间】:2017-10-25 01:15:32
【问题描述】:

我有一个文件夹结构,我需要用自定义名称复制它以启动项目 - 我已经研究过使用自定义函数修改 grunt-contrib-copy:

  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);

但这只是从我的数组中生成带有名称的文本文件,而不是多次复制文件夹及其内容。

谁能告诉我我哪里出了问题?

【问题讨论】:

    标签: javascript gruntjs grunt-contrib-copy grunt-init


    【解决方案1】:

    我最终使用 fs-extra 来复制目录,以防有人遇到同样的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-05
      • 2013-08-17
      • 2018-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多