# grunt-curl [![Donate on Gittip](http://badgr.co/gittip/twolfson.png)](https://www.gittip.com/twolfson/) Download files from the internet via grunt. ## Getting Started Install this grunt plugin next to your project's [grunt.js gruntfile][getting_started] with: `npm install grunt-curl` Then add this line to your project's `grunt.js` gruntfile: ```javascript grunt.loadNpmTasks('grunt-curl'); ``` [grunt]: http://gruntjs.com/ [getting_started]: https://github.com/gruntjs/grunt/blob/master/docs/getting_started.md ## Documentation `grunt-curl` retrieves data via [request][request]'s GET method and writes it to file. We register two grunt tasks ```js grunt.initConfig({ // Grab single files curl: { // Short format (dest: src) 'location/to/download/file.js': 'http://files.com/path/to/file.js', // Long format long: { src: 'http://files.com/path/to/file.js', dest: 'location/to/download/file.js' } }, // Grab multiple files 'curl-dir': { // Short format (dest folder: [src1, src2]) // These will be saved as 'location/to/save/files/file1.js' // and 'location/to/save/files/file2.js' 'location/to/save/files': [ 'http://files.com/path/to/file1.js', 'http://generic.com/scripts/file2.js' ], // Long format long: { src: [ 'http://files.com/path/to/file1.js', 'http://files.com/path/to/file2.js' ], dest: 'location/to/save/files' }, // src files will expand to same file1.js and file2.js as long format braceExpansion: { src: ['http://files.com/path/to/{file1,file2}.js'], dest: 'location/to/save/files' }, // Custom filepaths // This will save file1.js to location/to/save/files/path/to/file1.js // and file2.js to location/to/save/files/scripts/file2.js customFilepaths: { src: [ 'http://files.com/path/to/file1.js', 'http://generic.com/scripts/file2.js' ], router: function (url) { return url.replace('http://files.com/', '').replace('http://generic.com/', ''); }, dest: 'location/to/save/files' } } }): ``` and a grunt helper ```js grunt.helper('curl', url, function handleData (err, content) { // Handle error and use content }); ``` [request]: https://github.com/mikeal/request ## Contributing In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint your code using [grunt][grunt] and test via `npm test`. ## License Copyright (c) 2013 Todd Wolfson Licensed under the MIT license.