grunt-contrib-copy icon indicating copy to clipboard operation
grunt-contrib-copy copied to clipboard

Copy files from one directory to root of project

Open phun-ky opened this issue 11 years ago • 3 comments

I'm trying to copy a set of files from a subfolder of the project to the root of the project, with no luck. I tried to set the dest attribute to . or .. or ./ or ../ with no luck. I manage to accomplish what I wanted with a workaround, but it has to be a better way than this?

copy : {
  dist_files : {
    expand : true,
    flatten : true,
    src : 'js/app/dist/*',
    dest : '../../../',
    rename : function(dest, src){

      return __dirname + "\\" + src.replace('123-loader', 'loader');

    }
  }
}  

phun-ky avatar Sep 22 '14 11:09 phun-ky

dest: '' worked for me - give that a go?

furzeface avatar Sep 27 '14 16:09 furzeface

@phun-ky have you tried to use the cwd option ?

You could do

copy : {
  dist_files : {
    expand : true,
    cwd : 'js/app/dist',
    src: ['*'],
    dest : '../../../'
  }
}  

By the way, I'm not sure you said everything about your use case. I don't understand the need for the rename option.

stephanebachelier avatar Oct 27 '14 13:10 stephanebachelier

@furzeface thank you for your answer,I am puzzled all thie morning,I try dest:'/' and dest:'../' with failure.the correct way is dest:''.

guguji5 avatar Nov 25 '16 06:11 guguji5