Closed goldenlove closed 11 years ago
btw: i must use Long format configuration.....
Great question! My first thought would be to use a helper function to get around whatever config issues you are having.
function getCurlFile(shortpath) {
return {
src: 'http://host.com/' + shortpath,
dest: 'scripts' + shortpath
};
}
grunt.initConfig({
curl: {
hello: getCurlFile('hello.js'),
world: getCurlFile('world.js')
}
});
For the long term, I would love to see a new grunt task called curl-dir
or something similar.
Unfortunately, you cannot just curl
a directory for its contents. At least not in a consistent manner.
As a result, we still need to list out every item. But we can use the same curl
helper and even leverage the brace expansion of minimatch (what grunt uses) to simplify the file naming.
grunt.initConfig({
'grunt-dir': {
batch: {
// Files to download
src: ['http://host.com/file1.js', 'http://host.com/file2.js'],
// Directory to download file1.js and file2.js to
dest: 'scripts'
},
braceExpansion: {
// Expands to file1.js and file2.js
src: ['http://host.com/{file1,file2}.js'],
// Downloads file1.js and file2.js to scripts folder
dest: 'scripts'
},
}
});
I would prefer this stays in the same repo since they are so related. The reason I am choosing to not toss some fancy logic into the curl task is to alleviate potential confusion and any future enhancement issues.
^ ^" thanks 4 ur reply~
i just try 2 add long1: { ... }, long2: { .. } in curl task configuration..... it seems run well for me? -__-
i'l try the helper way now... thanks again.
Glad to hear I could be of help. I will now open an issue against myself for that curl-dir
task.
I have completed the curl-dir
task and can be found in version 0.3.0
on npm
.
Let me know if you have any trouble. Thanks =)
Thanks for your hardly work~ curl-dir
seems so cool for batch download.
hm~ but i just update to grunt@0.4.0rc7 and grunt-curl@0.3.0 , when i run my curl task.
it return some Warning:
Warning: Cannot read property 'src' of undefined
i don't know what's wrong with my config:
curl: {
long: {
src: 'some/path/to/index.php',
dest: 'pub/index.html'
}
}
I am currently sticking to supporting only grunt@0.3.x
at the moment =/
By default, people will receive grunt@0.3.x
when installing via npm install -g grunt
. I am not sure why grunt@0.4.x
is not backwards compatible with 0.3.x
plugins but it is. Sorry that I cannot be more assistive at the moment.
ok, i know~ that maybe grunt@0.4.x
change something wrong?... >.<
i'l try 2 fix it myself,
and hope you support grunt@0.4.x
when it pub to npm.
Yep, sorry about not being able to help. I will definitely support 0.4.x
when it becomes the flagship version.
If you do wind up fixing your issues for 0.4.x
, I would love to see a pull request about it so it can speed up the process when 0.4.x
happens.
^ ^" i'v temporary fix for 0.4.x
, my task was run finally now.
but i think is not the best way for this issues, so i doesn't pulled request.
just show my step here, hope this helps:
or how to create more task with curl ...?