Code Monkey home page Code Monkey logo

Comments (19)

Abdull avatar Abdull commented on August 21, 2024 1

To recap the answers to @webberig's initial question:
Instead of:

    copy: {
        bootstrap: {
            files: [
                {
                    src: ['components/bootstrap/img/*'],
                    dest: 'web/img/bootstrap/'
                }
            ]
        }
    }

try the following:

    copy: {
        bootstrap: {
            files: [
                {
                    expand: true,
                    cwd: 'components/bootstrap/img/'
                    src: ['*'],
                    dest: 'web/img/bootstrap/'
                }
            ]
        }
    }

With this setup, a file components/bootstrap/img/myFile.png is copied to web/img/bootstrap/myFile.png.

from grunt-contrib-copy.

tkellen avatar tkellen commented on August 21, 2024

Please see: http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically

from grunt-contrib-copy.

webberig avatar webberig commented on August 21, 2024

Thanks for your comment, tkellen.

I understand now this is not a bug, but at least consider this to be a usability error... My oppinion still stands that the behavior is odd. One would expect that the given example in the OP would be the same as a common file copy command:

cp components/bootstrap/img/* web/img/bootstrap

Copying files like this always copies the contents of the given folder, and does not copy the directory explicitly.

from grunt-contrib-copy.

jozefdransfield avatar jozefdransfield commented on August 21, 2024

Does the cwd property work?

{expand: true, cwd: ['public/assets/'], src:["swf/**"], dest: 'public/dist/<%= pkg.version %>/'}

this matches no files, but

{expand: true, cwd: ['public/assets/swf/'], src:["**"], dest: 'public/dist/<%= pkg.version %>/'}

copies the whole of my project into the dest directory, and

{expand: true, src:["public/assets/swf/**"], dest: 'public/dist/<%= pkg.version %>/'}

copies the right files but with all their parent directories under the dest dir?

from grunt-contrib-copy.

tkellen avatar tkellen commented on August 21, 2024

Can you post your output with --verbose for these?

from grunt-contrib-copy.

Dakuan avatar Dakuan commented on August 21, 2024

I'm pretty confused by this also...should add it was easily fixed by using cwd, but was confused by the behaviour all the same :)

from grunt-contrib-copy.

tkellen avatar tkellen commented on August 21, 2024

Your cwd needs to be a string, not an array.

from grunt-contrib-copy.

mwheeler avatar mwheeler commented on August 21, 2024

This still seems to be an issue, having a quick look into it seems to make me think 'src' should be prefixed by 'cwd' when iterating over the 'filePair' elements in the task.

grunt.file.copy is essentially being passed a file relative to cwd, when not actually trying to copy relative to cwd (thus the path prefix is missing for the source file - resulting in a ENOENT error because the path is wrong).

1 line lazy fix (src = (filePair.cwd || '') + src;) fixes this for me.

from grunt-contrib-copy.

tkellen avatar tkellen commented on August 21, 2024

The source should not be prefixed by the cwd, cwd works as though you are copying from within that directory. If you need paths higher than the cwd included in the copy, set your cwd to that path instead.

from grunt-contrib-copy.

coolaj86 avatar coolaj86 commented on August 21, 2024

cwd seems to be ignored?

snippit from Gruntfile.js

, copy: {
      main: {
          files: [
              { cwd: 'browser/', src: ['app.js'], dest: 'public/'}
            , { cwd: 'browser', src: ['jquery.js'], dest: 'public'}
          ]
      }
  }

Output of grunt --verbose

Running "copy:main" (copy) task
Verifying property copy.main exists in config...OK
Files: app.js -> public/
Files: jquery.js -> public/
Options: processContent=false, processContentExclude=[]
Copying app.js -> public/app.js
Reading app.js...ERROR
Warning: Unable to read "app.js" file (Error code: ENOENT). Use --force to continue.

from grunt-contrib-copy.

coolaj86 avatar coolaj86 commented on August 21, 2024

Hmm... added in expand: true and now it works. But I'm not expanding anything.

from grunt-contrib-copy.

tkellen avatar tkellen commented on August 21, 2024

You are expanding the wildcard in your src to create a bunch of src -> dest
pairs.
Http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically

On Apr 18, 2013, at 4:56 PM, AJ ONeal [email protected] wrote:

Hmm... added in expand: true and now it works. But I'm not expanding
anything.


Reply to this email directly or view it on
GitHubhttps://github.com//issues/60#issuecomment-16613716
.

from grunt-contrib-copy.

coolaj86 avatar coolaj86 commented on August 21, 2024

I don't have a wildcard in my src.

from grunt-contrib-copy.

tkellen avatar tkellen commented on August 21, 2024

Ah, right you are. That's what I get for responding quickly via my phone. So, expand triggers the usage of the cwd option, otherwise it won't do anything. Eventually that won't be the case, but right now it is. If you'd like to see it fixed, please open an issue on the grunt issue tracker.

from grunt-contrib-copy.

gregwym avatar gregwym commented on August 21, 2024

Finally I find an explanation for expand. Properties/options like expand and rename are useful, and prob should be better documented.

from grunt-contrib-copy.

tomlancaster avatar tomlancaster commented on August 21, 2024

+1 for totaly confused by this behavior. Why on earth wouldn't you want to emulate every other copy / cp command the world has ever seen?

from grunt-contrib-copy.

yanickrochon avatar yanickrochon commented on August 21, 2024

I also had an issue with this and adding expand:true even though I don't expand anything works.

This should be noted; using cwd requires expand to be true... it should perhaps be defaulted to true if undefined.

from grunt-contrib-copy.

ptica avatar ptica commented on August 21, 2024

ok

expand: true,
cwd: 'Vendor/bootstrap/fonts',
src: '*',
dest:'webroot/fonts/'

is definitely the most strange syntax for what used to be

cp Vendor/bootstrap/fonts/* webroot/fonts/

in the old days of Makefiles

from grunt-contrib-copy.

faebser avatar faebser commented on August 21, 2024
fonts: {
                src: 'css/fonts/**/*',
                dest: 'dist/'
            }

leadings to the following behavior:

Running "copy:fonts" (copy) task
Verifying property copy.fonts exists in config...OK
Files: css/fonts/generator_config.txt, css/fonts/icomoon.eot, css/fonts/icomoon.svg, css/fonts/icomoon.ttf, css/fonts/icomoon.woff, css/fonts/opensans-bold-webfont.eot, css/fonts/opensans-bold-webfont.ttf, css/fonts/opensans-bold-webfont.woff, css/fonts/opensans-bold-webfont.woff2, css/fonts/opensans-light-webfont.eot, css/fonts/opensans-light-webfont.ttf, css/fonts/opensans-light-webfont.woff, css/fonts/opensans-light-webfont.woff2 -> dist/
Options: encoding="utf8", processContent=false, processContentExclude=[], timestamp=false, mode=false
Copying css/fonts/generator_config.txt -> dist/css/fonts/generator_config.txt
Reading css/fonts/generator_config.txt...OK
Writing dist/css/fonts/generator_config.txt...OK
Copying css/fonts/icomoon.eot -> dist/css/fonts/generator_config.txt
Reading css/fonts/icomoon.eot...OK
Writing dist/css/fonts/generator_config.txt...OK
Copying css/fonts/icomoon.svg -> dist/css/fonts/generator_config.txt
Reading css/fonts/icomoon.svg...OK
Writing dist/css/fonts/generator_config.txt...OK
Copying css/fonts/icomoon.ttf -> dist/css/fonts/generator_config.txt
Reading css/fonts/icomoon.ttf...OK
Writing dist/css/fonts/generator_config.txt...OK
Copying css/fonts/icomoon.woff -> dist/css/fonts/generator_config.txt
Reading css/fonts/icomoon.woff...OK
Writing dist/css/fonts/generator_config.txt...OK
Copying css/fonts/opensans-bold-webfont.eot -> dist/css/fonts/generator_config.txt
Reading css/fonts/opensans-bold-webfont.eot...OK
Writing dist/css/fonts/generator_config.txt...OK
Copying css/fonts/opensans-bold-webfont.ttf -> dist/css/fonts/generator_config.txt
Reading css/fonts/opensans-bold-webfont.ttf...OK
Writing dist/css/fonts/generator_config.txt...OK
Copying css/fonts/opensans-bold-webfont.woff -> dist/css/fonts/generator_config.txt
Reading css/fonts/opensans-bold-webfont.woff...OK
Writing dist/css/fonts/generator_config.txt...OK
Copying css/fonts/opensans-bold-webfont.woff2 -> dist/css/fonts/generator_config.txt
Reading css/fonts/opensans-bold-webfont.woff2...OK
Writing dist/css/fonts/generator_config.txt...OK
Copying css/fonts/opensans-light-webfont.eot -> dist/css/fonts/generator_config.txt
Reading css/fonts/opensans-light-webfont.eot...OK
Writing dist/css/fonts/generator_config.txt...OK
Copying css/fonts/opensans-light-webfont.ttf -> dist/css/fonts/generator_config.txt
Reading css/fonts/opensans-light-webfont.ttf...OK
Writing dist/css/fonts/generator_config.txt...OK
Copying css/fonts/opensans-light-webfont.woff -> dist/css/fonts/generator_config.txt
Reading css/fonts/opensans-light-webfont.woff...OK
Writing dist/css/fonts/generator_config.txt...OK
Copying css/fonts/opensans-light-webfont.woff2 -> dist/css/fonts/generator_config.txt
Reading css/fonts/opensans-light-webfont.woff2...OK
Writing dist/css/fonts/generator_config.txt...OK
Copied 13 files

Why does it write everything into the same file?

from grunt-contrib-copy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.