source: Dev/trunk/node_modules/grunt-curl/README.md @ 532

Last change on this file since 532 was 484, checked in by hendrikvanantwerpen, 11 years ago

Commit node_modules, to make checkouts and builds more deterministic.

File size: 2.5 KB
RevLine 
[484]1# grunt-curl [![Donate on Gittip](http://badgr.co/gittip/twolfson.png)](https://www.gittip.com/twolfson/)
2
3Download files from the internet via grunt.
4
5## Getting Started
6Install this grunt plugin next to your project's [grunt.js gruntfile][getting_started] with: `npm install grunt-curl`
7
8Then add this line to your project's `grunt.js` gruntfile:
9
10```javascript
11grunt.loadNpmTasks('grunt-curl');
12```
13
14[grunt]: http://gruntjs.com/
15[getting_started]: https://github.com/gruntjs/grunt/blob/master/docs/getting_started.md
16
17## Documentation
18`grunt-curl` retrieves data via [request][request]'s GET method and writes it to file.
19
20We register two grunt tasks
21```js
22grunt.initConfig({
23  // Grab single files
24  curl: {
25    // Short format (dest: src)
26    'location/to/download/file.js': 'http://files.com/path/to/file.js',
27
28    // Long format
29    long: {
30      src: 'http://files.com/path/to/file.js',
31      dest: 'location/to/download/file.js'
32    }
33  },
34  // Grab multiple files
35  'curl-dir': {
36    // Short format (dest folder: [src1, src2])
37    // These will be saved as 'location/to/save/files/file1.js'
38    //    and 'location/to/save/files/file2.js'
39    'location/to/save/files': [
40      'http://files.com/path/to/file1.js',
41      'http://generic.com/scripts/file2.js'
42    ],
43
44    // Long format
45    long: {
46      src: [
47        'http://files.com/path/to/file1.js',
48        'http://files.com/path/to/file2.js'
49      ],
50      dest: 'location/to/save/files'
51    },
52
53    // src files will expand to same file1.js and file2.js as long format
54    braceExpansion: {
55      src: ['http://files.com/path/to/{file1,file2}.js'],
56      dest: 'location/to/save/files'
57    },
58
59    // Custom filepaths
60    // This will save file1.js to location/to/save/files/path/to/file1.js
61    //    and file2.js to location/to/save/files/scripts/file2.js
62    customFilepaths: {
63      src: [
64        'http://files.com/path/to/file1.js',
65        'http://generic.com/scripts/file2.js'
66      ],
67      router: function (url) {
68        return url.replace('http://files.com/', '').replace('http://generic.com/', '');
69      },
70      dest: 'location/to/save/files'
71    }
72  }
73}):
74```
75
76and a grunt helper
77```js
78grunt.helper('curl', url, function handleData (err, content) {
79  // Handle error and use content
80});
81```
82
83[request]: https://github.com/mikeal/request
84
85## Contributing
86In 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`.
87
88## License
89Copyright (c) 2013 Todd Wolfson
90Licensed under the MIT license.
Note: See TracBrowser for help on using the repository browser.