Jack Roscoe
Jack Roscoe

Reputation: 4313

Why is grunt-contrib-copy writing all my files with the same name?

I'm running grunt-contrib-copy to copy a set of images from one directory to another. All of the files are getting copied, but each copy is being written with the name of the first file in the queue so I'm ending up with only one file.

Here's my config:

copy: {
    regImages: {
        src: [
          'images/*'
        ],
        dest: 'dist/'
    }
}

Here's the verbose output from my CLI after running the command:

Running "copy:regImages" (copy) task
Verifying property copy.regImages exists in config...OK
Files: images/favicon.png, images/favicon_dev.png, images/favicon_staging.png, images/
sprites, images/svg -> dist/
Options: encoding="utf8", processContent=false, processContentExclude=[], 
timestamp=false, mode=false
Copying images/favicon.png -> dist/images/favicon.png
Reading images/favicon.png...OK
Writing dist/images/favicon.png...OK
Copying images/favicon_dev.png -> dist/images/favicon.png
Reading images/favicon_dev.png...OK
Writing dist/images/favicon.png...OK
Copying images/favicon_staging.png -> dist/images/favicon.png
Reading images/favicon_staging.png...OK
Writing dist/images/favicon.png...OK
Creating dist/images/favicon.png
Creating dist/images/favicon.png
Created 2 directories, copied 3 files

Why aren't the files being written with there original names?

Upvotes: 1

Views: 99

Answers (1)

Matt Montag
Matt Montag

Reputation: 7481

You have to include the expand: true property in your regImages object.

(I'm not sure why this isn't the default behavior; it's not documented very well.)

Upvotes: 2

Related Questions