Comments (19)
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.
Please see: http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically
from grunt-contrib-copy.
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.
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.
Can you post your output with --verbose
for these?
from grunt-contrib-copy.
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.
Your cwd
needs to be a string, not an array.
from grunt-contrib-copy.
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.
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.
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.
Hmm... added in expand: true
and now it works. But I'm not expanding anything.
from grunt-contrib-copy.
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.
I don't have a wildcard in my src
.
from grunt-contrib-copy.
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.
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.
+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.
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.
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.
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)
- hide page HOT 1
- What is it do when copy?
- syncTimestamp running even if timestamp option is false HOT 2
- Document options HOT 1
- Using expand with --no-write fails
- timestampEqual test fails on i386 Linux
- file not copied [no src] HOT 1
- Question than issue
- Copy task not working in windows running forever HOT 5
- Audio files are breaking :'( HOT 1
- Process Function Corrupts Images and fons files
- How to resolve the below error ? HOT 2
- Replace not working with multiple files.
- .filename not copied with src: **/**
- node Assertion failed on copy HOT 3
- Decompose list and move the files in the list to an existing directory
- Xgboost and Bayesian Optimization HOT 1
- Slow on windows HOT 2
- Grunt-Copy-JS annoying Warning: EPERM: operation not permitted, futime Use --force to continue. HOT 2
- Copy files is broken after update Grunt v1.6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-contrib-copy.