Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

v2

  • Loading branch information...
commit f4c60e8f223dde3b904b736b3d8e6f3d0d613183 1 parent db7d7c9
@tkellen tkellen authored
Showing with 46 additions and 2,702 deletions.
  1. +1 −3 .gitignore
  2. +0 −2  .npmignore
  3. +16 −12 CHANGELOG
  4. +14 −22 README.md
  5. +0 −2  bin/grunt-contrib
  6. +0 −23 docs/bump.md
  7. +0 −45 docs/clean.md
  8. +0 −42 docs/coffee.md
  9. +0 −86 docs/compress.md
  10. +0 −73 docs/copy.md
  11. +0 −77 docs/handlebars.md
  12. +0 −50 docs/helpers.md
  13. +0 −106 docs/jade.md
  14. +0 −49 docs/jst.md
  15. +0 −41 docs/less.md
  16. +0 −29 docs/mincss.md
  17. +0 −30 docs/requirejs.md
  18. +0 −49 docs/stylus.md
  19. +0 −41 docs/yuidoc.md
  20. +0 −28 grunt.js
  21. +15 −48 package.json
  22. +0 −37 tasks/bump.js
  23. +0 −35 tasks/clean.js
  24. +0 −59 tasks/coffee.js
  25. +0 −232 tasks/compress.js
  26. +0 −101 tasks/copy.js
  27. +0 −102 tasks/handlebars.js
  28. +0 −72 tasks/helpers.js
  29. +0 −68 tasks/jade.js
  30. +0 −57 tasks/jst.js
  31. +0 −73 tasks/less.js
  32. +0 −44 tasks/mincss.js
  33. +0 −45 tasks/requirejs.js
  34. +0 −73 tasks/stylus.js
  35. +0 −65 tasks/yuidoc.js
  36. +0 −13 test/bump_test.js
  37. +0 −13 test/clean_task.js
  38. +0 −17 test/coffee_test.js
  39. +0 −103 test/compress_test.js
  40. +0 −32 test/copy_test.js
  41. +0 −2  test/fixtures/coffee/coffee_basic.coffee
  42. +0 −1  test/fixtures/coffee/coffee_second.coffee
  43. +0 −1  test/fixtures/compress/folder_one/one.css
  44. +0 −1  test/fixtures/compress/folder_one/one.js
  45. +0 −1  test/fixtures/compress/folder_two/two.css
  46. +0 −1  test/fixtures/compress/folder_two/two.js
  47. +0 −1  test/fixtures/compress/test.css
  48. +0 −1  test/fixtures/compress/test.js
  49. +0 −1  test/fixtures/copy/.hidden
  50. +0 −1  test/fixtures/copy/folder_one/one.css
  51. +0 −1  test/fixtures/copy/folder_one/one.js
  52. +0 −1  test/fixtures/copy/folder_two/two.css
  53. +0 −1  test/fixtures/copy/folder_two/two.js
  54. +0 −1  test/fixtures/copy/test.css
  55. +0 −1  test/fixtures/copy/test.js
  56. +0 −1  test/fixtures/handlebars/_partial.handlebar
  57. +0 −1  test/fixtures/handlebars/one.handlebar
  58. +0 −4 test/fixtures/jade/inc/head.jade
  59. +0 −4 test/fixtures/jade/jade.jade
  60. +0 −4 test/fixtures/jade/jade2.jade
  61. +0 −4 test/fixtures/jade/jadeInclude.jade
  62. +0 −1  test/fixtures/jade/jadeTemplate.jade
  63. +0 −1  test/fixtures/jst/template.html
  64. +0 −1  test/fixtures/less/include/variables.less
  65. +0 −4 test/fixtures/less/style.less
  66. +0 −4 test/fixtures/less/style2.less
  67. +0 −5 test/fixtures/mincss/input_one.css
  68. +0 −4 test/fixtures/mincss/input_two.css
  69. +0 −1  test/fixtures/requirejs/hello.js
  70. +0 −3  test/fixtures/requirejs/project.js
  71. +0 −1  test/fixtures/requirejs/world.js
  72. +0 −1  test/fixtures/stylus/include/variables.styl
  73. +0 −4 test/fixtures/stylus/stylus.styl
  74. +0 −3  test/fixtures/stylus/stylus2.styl
  75. +0 −27 test/fixtures/yuidoc/app/test.js
  76. +0 −27 test/fixtures/yuidoc/otherapp/test.js
  77. +0 −272 test/grunt.js
  78. +0 −14 test/handlebars_test.js
  79. +0 −25 test/jade_test.js
  80. +0 −13 test/jst_test.js
  81. +0 −25 test/less_test.js
  82. +0 −13 test/mincss_test.js
  83. +0 −51 test/options_test.js
  84. +0 −22 test/requirejs_test.js
  85. +0 −17 test/stylus_test.js
  86. +0 −30 test/yuidoc_test.js
View
4 .gitignore
@@ -1,5 +1,3 @@
-.DS_Store
node_modules
npm-debug.log
-test/fixtures/output
-.idea
+tmp
View
2  .npmignore
@@ -1,2 +0,0 @@
-/node_modules/
-/test/fixtures/output/
View
28 CHANGELOG
@@ -1,65 +1,69 @@
Until v1, this will only be updated when major or breaking changes are made.
-2012.08.27, Version 0.1.8
+2012.09.10, v0.2.0
+
+* converted to grunt collection, all tasks in separate repos/packages.
+
+2012.08.27, v0.1.8
* update dependencies to latest versions.
* bump: new task to assist with versioning (PR #111)
-2012.08.20, Version 0.1.7
+2012.08.20, v0.1.7
* add partial support to handlebars task (PR #106)
* update package.json for latest stylus (PR #104)
* copy: add minimatch option (PR #105)
-2012.08.13, Version 0.1.6
+2012.08.13, v0.1.6
* less+stylus: correct concat logic and add tests. (#101)
* handlebars: add processName
-2012.08.06, Version 0.1.5
+2012.08.06, v0.1.5
* add nib as dependancy
-2012.07.30, Version 0.1.4
+2012.07.30, v0.1.4
* copy: sort test arrays before compare (PR #93)
* copy+compress: use basePath left to right (GH #92)
* handlebars: fix failing test in 1.0.6
* less: prints 'undefined' when there are no stylesheets. (PR #89)
-2012.07.23, Version 0.1.3
+2012.07.23, v0.1.3
* bug fixes (#86)
* stylus: load nib if available (PR #87)
-2012.07.16, Version 0.1.2
+2012.07.16, v0.1.2
* bug fixes (#84)
* basePath overhaul
* lint in strict mode
* variable declaration cleanup
-2012.07.09, Version 0.1.1
+2012.07.09, v0.1.1
* bug fixes
* task overhaul
* yuidoc task addition
* prep for grunt v0.4
-2012.06.28, Version 0.0.9
+2012.06.28, v0.0.9
* task cleanup
* copy task addition
-2012.06.12, Version 0.0.7
+2012.06.12, v0.0.7
* requirejs task addition
-2012.06.03, Version 0.0.5
+2012.06.03, v0.0.5
* task cleanup
* zip task addition
-2012.05.01, Version 0.0.1
+2012.05.01, v0.0.1
* initial release
View
36 README.md
@@ -15,49 +15,45 @@ grunt.loadNpmTasks('grunt-contrib');
[getting_started]: https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
## Included Tasks
-#### [`bump`](/gruntjs/grunt-contrib/blob/master/docs/bump.md)
+#### [`bump`](/gruntjs/grunt-contrib-bump/)
Bump package version.
-#### [`clean`](/gruntjs/grunt-contrib/blob/master/docs/clean.md)
+#### [`clean`](/gruntjs/grunt-contrib-clean/)
Clear files and folders.
-#### [`coffee`](/gruntjs/grunt-contrib/blob/master/docs/coffee.md)
+#### [`coffee`](/gruntjs/grunt-contrib-coffee/)
Compile CoffeeScript files into JavaScript.
-#### [`compress`](/gruntjs/grunt-contrib/blob/master/docs/compress.md)
+#### [`compress`](/gruntjs/grunt-contrib-compress/)
Compress files and folders using gzip or zip.
-#### [`copy`](/gruntjs/grunt-contrib/blob/master/docs/copy.md)
+#### [`copy`](/gruntjs/grunt-contrib-copy/)
Copy files into another directory.
-#### [`handlebars`](/gruntjs/grunt-contrib/blob/master/docs/handlebars.md)
+#### [`handlebars`](/gruntjs/grunt-contrib-handlebars/)
Compile handlebars templates to JST file.
-#### [`jade`](/gruntjs/grunt-contrib/blob/master/docs/jade.md)
+#### [`jade`](/gruntjs/grunt-contrib-jade/)
Compile Jade templates to HTML.
-#### [`jst`](/gruntjs/grunt-contrib/blob/master/docs/jst.md)
+#### [`jst`](/gruntjs/grunt-contrib-jst/)
Compile underscore templates to JST file.
-#### [`less`](/gruntjs/grunt-contrib/blob/master/docs/less.md)
+#### [`less`](/gruntjs/grunt-contrib-less/)
Compile LESS files to CSS.
-#### [`mincss`](/gruntjs/grunt-contrib/blob/master/docs/mincss.md)
+#### [`mincss`](/gruntjs/grunt-contrib-mincss/)
Minify CSS files.
-#### [`requirejs`](/gruntjs/grunt-contrib/blob/master/docs/requirejs.md)
+#### [`requirejs`](/gruntjs/grunt-contrib-requirejs/)
Optimize RequireJS projects using r.js.
-#### [`stylus`](/gruntjs/grunt-contrib/blob/master/docs/stylus.md)
+#### [`stylus`](/gruntjs/grunt-contrib-stylus/)
Compile Stylus files into CSS. Preloaded with [nib](http://visionmedia.github.com/nib/).
-#### [`yuidoc`](/gruntjs/grunt-contrib/blob/master/docs/yuidoc.md)
+#### [`yuidoc`](/gruntjs/grunt-contrib-yuidoc/)
Compile YUIDoc Documentation.
-## Included Helpers
-### [`options`](/gruntjs/grunt-contrib/blob/master/docs/helpers.md#options)
-Unified options retrieval, will be replaced with grunt's built-in `this.options` in the near future.
-
## Bugs
Help us squash them by submitting an issue that describes how you encountered it; please be as specific as possible including operating system, node, grunt, and grunt-contrib versions.
@@ -120,8 +116,4 @@ or if you always want to ride on the edge:
"dependencies": {
"grunt-contrib": "git://github.com/gruntjs/grunt-contrib.git"
}
-```
-
-## License
-Copyright (c) 2012 "Cowboy" Ben Alman & contributors.
-Licensed under the MIT license.
+```
View
2  bin/grunt-contrib
@@ -1,2 +0,0 @@
-#!/usr/bin/env node
-require('grunt').npmTasks('grunt-contrib').cli();
View
23 docs/bump.md
@@ -1,23 +0,0 @@
-## Bump package version
-> Contributed By: [Vojta Jína](/vojtajina) (@vojtajina)
-
-#### Usage
-
-Let's say current version is `0.0.1`.
-
-```bash
-grunt bump
->> Version bumped to 0.0.2
-
-grunt bump:patch
->> Version bumped to 0.0.3
-
-grunt bump:minor
->> Version bumped to 0.1.0
-
-grunt bump
->> Version bumped to 0.1.1
-
-grunt bump:major
->> Version bumped to 1.0.0
-```
View
45 docs/clean.md
@@ -1,45 +0,0 @@
-## Clear files and folders.
-> Contributed By: [Tim Branyen](/tbranyen) (@tbranyen)
-
-### Overview
-
-Inside your `grunt.js` file, add a section named `clean`.
-
-Due to the destructive nature of this task, we have implemented several sanity checks but always be cautious of the paths you clean.
-
-#### Parameters
-
-##### src ```string```
-
-This defines what paths this task will clean recursively (supports [grunt.template](https://github.com/cowboy/grunt/blob/master/docs/api_template.md) and [minimatch](https://github.com/isaacs/minimatch)).
-
-#### Options
-
-#### Config Examples
-
-There are three different formats that you can use to run this task.
-
-##### Short
-
-``` javascript
-clean: ["path/to/dir/one", "path/to/dir/two"]
-```
-
-##### Medium (specific targets with global options)
-
-``` javascript
-clean: {
- build: ["path/to/dir/one", "path/to/dir/two"],
- release: ["path/to/another/dir/one", "path/to/another/dir/two"]
-},
-```
-
-##### Long (specific targets with per target options)
-
-``` javascript
-clean: {
- build: {
- src: ["path/to/dir/one", "path/to/dir/two"]
- }
-}
-```
View
42 docs/coffee.md
@@ -1,42 +0,0 @@
-## Compile CoffeeScript files to JavaScript
-> Contributed By: [Eric Woroshow](/errcw) (@errcw)
-
-### Overview
-
-Inside your `grunt.js` file add a section named `coffee`. This section specifies the files to compile and the options passed to [CoffeeScript](http://coffeescript.org/#usage).
-
-#### Parameters
-
-##### files ```object```
-
-This defines what files this task will process and should contain key:value pairs.
-
-The key (destination) should be an unique filepath (supports [grunt.template](https://github.com/cowboy/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)).
-
-Note: When the value contains an array of multiple filepaths, the contents are concatenated in the order passed.
-
-##### options ```object```
-
-This controls how this task (and its helpers) operate and should contain key:value pairs, see options below.
-
-#### Options
-
-##### bare ```boolean```
-
-Compile the JavaScript without the top-level function safety wrapper.
-
-#### Config Example
-
-``` javascript
-coffee: {
- compile: {
- options: {
- bare: true
- },
- files: {
- "path/to/result.js": "path/to/source.coffee",
- "path/to/another.js": ["path/to/sources/*.coffee", "path/to/more/*.coffee"]
- }
- }
-}
-```
View
86 docs/compress.md
@@ -1,86 +0,0 @@
-## Compress files and folders
-
-### Overview
-
-Inside your `grunt.js` file, add a section named `compress`. This section specifies the files to compress and the options passed to either [zipstream](https://github.com/wellawaretech/node-zipstream) (for zip) or [tar](https://github.com/isaacs/node-tar) (for tar/tgz) or [zlib](http://nodejs.org/api/zlib.html#zlib_options) (for gzip).
-
-#### Parameters
-
-##### files ```object```
-
-This defines what files this task will compress and should contain key:value pairs.
-
-The key (destination) should be an unique filepath (supports [grunt.template](https://github.com/cowboy/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)).
-
-##### options ```object```
-
-This controls how this task operates and should contain key:value pairs, see options below.
-
-#### Options
-
-##### mode ```string```
-
-This is used to define which mode to use, currently supports gzip, tar, tgz (tar gzip) and zip.
-
-##### basePath ```string```
-
-This option adjusts internal filenames to be relative to provided path, within the resulting archive file.
-
-##### flatten ```boolean```
-
-This option performs a flat copy that dumps all the files into the root of the destination file, overwriting files if they exist.
-
-##### level ```integer``` (zip only)
-
-This option sets the level of archive compression (defaults to 1).
-
-> Currently, gzip compression related options are not supported due to deficiencies in node's zlib library.
-
-#### Config Example
-
-``` javascript
-compress: {
- zip: {
- options: {
- mode: "zip",
- basePath: "path/to",
- level: 1
- },
- files: {
- "path/to/result.zip": "path/to/source/*", // includes files in dir
- "path/to/another.gz": "path/to/source/**", // includes files in dir and subdirs
- "path/to/final.zip": ["path/to/sources/*.js", "path/to/more/*.js"], // include JS files in two diff dirs
- "path/to/project-<%= pkg.version %>.zip": "path/to/source/**" // variables in destination
- }
- }
-
- tar: {
- options: {
- mode: "tar",
- basePath: "path/to"
- },
- files: {
- "path/to/result.tar": "path/to/file.ext"
- }
- },
-
- tgz: {
- options: {
- mode: "tgz",
- basePath: "path/to"
- },
- files: {
- "path/to/result.tgz": "path/to/file.ext"
- }
- },
-
- gzip: {
- options: {
- mode: "gzip"
- },
- files: {
- "path/to/result.gz": "path/to/file.ext"
- }
- }
-}
-```
View
73 docs/copy.md
@@ -1,73 +0,0 @@
-## Copy files into another directory
-
-### Recent Confusion
-
-Many expect this task to work like `cp` on *nix systems but it was designed to use grunt conventions including the use of minimatch regex. We are working hard to make this and other tasks suitable for advanced users but there are no current plans to emulate `cp`.
-
-### Configuration
-
-Inside your `grunt.js` file add a section named `copy`. This section specifies the files to copy.
-
-#### Parameters
-
-##### files ```object```
-
-This defines what files this task will copy and should contain key:value pairs.
-
-The key (destination) should be an unique path (supports [grunt.template](https://github.com/cowboy/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)).
-
-##### options ```object```
-
-This controls how this task operates and should contain key:value pairs, see options below.
-
-#### Options
-
-##### basePath ```string```
-
-This option adjusts the folder structure when copied to the destination directory. When not explicitly set, best effort is made to locate the basePath by comparing all source filepaths left to right for a common pattern.
-
-##### flatten ```boolean```
-
-This option performs a flat copy that dumps all the files into the root of the destination directory, overwriting files if they exist.
-
-##### processName ```function```
-
-This option accepts a function that adjusts the filename of the copied file. Function is passed filename and should return a string.
-
-``` javascript
-options: {
- processName: function(filename) {
- if (filename == "test.jpg") {
- filename = "newname.jpg";
- }
- return filename;
- }
-}
-```
-
-##### processContent ```function```
-
-This option is passed to `grunt.file.copy` as an advanced way to control the file contents that are copied.
-
-##### processContentExclude ```string```
-
-This option is passed to `grunt.file.copy` as an advanced way to control which file contents are processed.
-
-##### minimatch ```object```
-
-These options will be forwarded on to expandFiles, as referenced in the [minimatch options section](https://github.com/isaacs/minimatch/#options)
-
-#### Config Example
-
-``` javascript
-copy: {
- dist: {
- files: {
- "path/to/directory": "path/to/source/*", // includes files in dir
- "path/to/directory": "path/to/source/**", // includes files in dir and subdirs
- "path/to/project-<%= pkg.version %>": "path/to/source/**", // variables in destination
- "path/to/directory": ["path/to/sources/*.js", "path/to/more/*.js"] // include JS files in two diff dirs
- }
- }
-}
-```
View
77 docs/handlebars.md
@@ -1,77 +0,0 @@
-## Compile handlebars templates to JST file
-> Contributed By: [Tim Branyen](/tbranyen) (@tbranyen)
-
-### Overview
-
-Inside your `grunt.js` file, add a section named `handlebars`. This section specifies the files to compile and the options used with [handlebars](http://handlebarsjs.com/).
-
-##### files ```object```
-
-This defines what files this task will process and should contain key:value pairs.
-
-The key (destination) should be an unique filepath (supports [grunt.template](https://github.com/cowboy/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)).
-
-Note: Values are precompiled to the namespaced JST array in the order passed.
-
-##### options ```object```
-
-This controls how this task operates and should contain key:value pairs, see options below.
-
-#### Options
-
-##### namespace ```string```
-
-The namespace in which the resulting JST templates are assigned to.
-
-##### processName ```function```
-
-This option accepts a function which takes one argument (the template filepath) and returns a string which will be used as the key for the precompiled template object. The example below stores all templates on the default JST namespace in capital letters.
-
-``` javascript
-options: {
- processName: function(filename) {
- return filename.toUpperCase();
- }
-}
-```
-
-##### processPartialName ```function```
-
-This option accepts a function which takes one argument (the partial filepath) and returns a string which will be used as the key for the precompiled partial object when it is registered in Handlebars.partials. The example below stores all partials using only the actual filename instead of the full path.
-
-``` javascript
-options: {
- processPartialName: function(filePath) { // input: templates/_header.handlebar
- var pieces = filePath.split("/");
- return pieces[pieces.length - 1]; // output: _header.handlebar
- }
-}
-````
-
-Note: If processPartialName is not provided as an option the default assumes that partials will be stored by stripping trailing underscore characters and filename extensions. For example, the path *templates/_header.handlebar* will become *header* and can be referenced in other templates as *{{> header}}*.
-
-##### partialRegex ```regex```
-
-This option accepts a regex that defines the prefix character that is used to identify Handlebars partial files. (The default is _).
-
-``` javascript
-options: {
- partialRegex: /^par_/ // assumes partial files would be prefixed with "par_" ie: "par_header.handlebar"
-}
-```
-
-#### Config Example
-
-``` javascript
-handlebars: {
- compile: {
- options: {
- namespace: "JST"
- },
- files: {
- "path/to/result.js": "path/to/source.handlebar",
- "path/to/another.js": ["path/to/sources/*.handlebar", "path/to/more/*.handlebar"]
- }
- }
-}
-```
View
50 docs/helpers.md
@@ -1,50 +0,0 @@
-# Helpers
-
-Several helpers are included as part of grunt-contrib, often to help improve consistency between tasks.
-
-## Included Helpers
-
-### Options
-> Contributed By: [Tyler Kellen](/tkellen) (@tkellen)
-
-#### Overview
-
-This helper will retrieve an options object from the global options.task key. If a subtask has been defined, data in options.task.subtask can override keys in options.task. Finally, an options object defined directly in the task key will override all.
-
-#### Parameters
-
-##### data
-
-This parameter is used to find out the current task, commonly passed ```this``` from within tasks.
-
-##### defaults
-
-This parameter allows developers to define sensible default options that are set if user neglected to set them.
-
-#### Usage
-
-```javascript
-var options = grunt.helper("options", this, {fallback: true}); // loads options for current task
-```
-
-#### Config
-
-
-```javascript
-options: {
- task: {
- param: 'default',
- subtask: {
- param: 'override default'
- }
- }
-},
-
-task: {
- subtask: {
- options: {
- param: 'override all'
- }
- }
-}
-```
View
106 docs/jade.md
@@ -1,106 +0,0 @@
-## Compile Jade files to HTML
-> Contributed By: [Eric Woroshow](/errcw) (@errcw)
-
-### Overview
-
-Inside your `grunt.js` file add a section named `jade`. This section specifies files to compile and the options passed to [jade](https://github.com/visionmedia/jade#public-api).
-
-#### Parameters
-
-##### files ```object```
-
-This defines what files this task will process and should contain key:value pairs.
-
-The key (destination) should be an unique filepath (supports [grunt.template](https://github.com/cowboy/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)).
-
-Note: When the value contains an array of multiple filepaths, the contents are concatenated in the order passed.
-
-##### options ```object```
-
-This controls how this task (and its helpers) operate and should contain key:value pairs, see options below.
-
-#### Options
-
-##### data ```object```
-
-Sets the data passed to ```jade``` during template compilation. Any data can be passed to the template (including ```grunt``` templates).
-
-#### Config Examples
-
-``` javascript
-jade: {
- compile: {
- options: {
- data: {
- debug: false
- }
- },
- files: {
- "path/to/dest.html": ["path/to/templates/*.jade", "another/path/tmpl.jade"]
- }
- }
-}
-```
-
-If you want to generate a debug file and a release file from the same template:
-
-``` javascript
-jade: {
- debug: {
- options: {
- data: {
- debug: true
- }
- },
- files: {
- "debug.html": "test.jade"
- }
- },
- release: {
- options: {
- data: {
- debug: false
- }
- },
- files: {
- "release.html": "test.jade"
- }
- }
-}
-```
-
-If you want to use `grunt` template in `options.data`:
-
-``` javascript
-jade: {
- debug: {
- options: {
- data: {
- debug: true,
- timestamp: "<%= new Date().getTime() %>"
- }
- },
- files: {
- "debug.html": "test.jade"
- }
- }
-}
-```
-
-or you can use `grunt` helpers (grunt object was exposed at template context):
-
-``` javascript
-jade: {
- debug: {
- options: {
- data: {
- debug: true,
- timestamp: "<%= grunt.template.today() %>"
- }
- },
- files: {
- "debug.html": "test.jade"
- }
- }
-}
-```
View
49 docs/jst.md
@@ -1,49 +0,0 @@
-## Compile underscore templates to JST file
-> Contributed By: [Tim Branyen](/tbranyen) (@tbranyen)
-
-### Overview
-
-This task compiles Underscore compatible templates into functions that can be concatenated and minified with existing source files.
-
-Inside your `grunt.js` file, add a section named `jst`. This section specifies the files to compile and the options passed to [underscore.template](http://underscorejs.org/#template).
-
-#### Parameters
-
-##### files ```object```
-
-This defines what files this task will process and should contain key:value pairs.
-
-The key (destination) should be an unique filepath (supports [grunt.template](https://github.com/cowboy/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)).
-
-Note: Values are precompiled to the namespaced JST array in the order passed.
-
-##### options ```object```
-
-This controls how this task (and its helpers) operate and should contain key:value pairs, see options below.
-
-#### Options
-
-##### namespace ```string```
-
-The namespace in which the resulting JST templates are assigned to.
-
-##### templateSettings ```object```
-
-The settings passed to underscore when compiling templates.
-
-#### Config Examples
-
-``` javascript
-jst: {
- compile: {
- options: {
- templateSettings: {
- interpolate : /\{\{(.+?)\}\}/g
- }
- },
- files: {
- "path/to/compiled/templates.js": ["path/to/source/**/*.html"]
- }
- }
-}
-```
View
41 docs/less.md
@@ -1,41 +0,0 @@
-## Compile LESS files to CSS
-> Contributed By: [Tyler Kellen](/tkellen) (@tkellen)
-
-### Overview
-
-Inside your `grunt.js` file add a section named `less`. This section specifies the files to compile and the options passed to [LESS](http://lesscss.org/#-server-side-usage).
-
-#### Parameters
-
-##### files ```object```
-
-This defines what files this task will process and should contain key:value pairs.
-
-The key (destination) should be an unique filepath (supports [grunt.template](https://github.com/cowboy/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)).
-
-Note: When the value contains an array of multiple filepaths, the contents are concatenated in the order passed.
-
-##### options ```object```
-
-This controls how this task (and its helpers) operate and should contain key:value pairs, see options below.
-
-#### Options
-
-##### paths ```string|array```
-
-This specifies directories to scan for @import directives when parsing.
-
-#### Config Example
-
-``` javascript
-less: {
- compile: {
- options: {
- paths: ["assets/css"]
- },
- files: {
- "path/to/result.css": "path/to/source.less"
- }
- }
-}
-```
View
29 docs/mincss.md
@@ -1,29 +0,0 @@
-## Minify CSS files
-> Contributed By: [Tim Branyen](/tbranyen) (@tbranyen)
-
-### Configuration
-
-Inside your `grunt.js` file, add a section named `mincss`. This section specifies the files to compress with [clean-css](https://github.com/GoalSmashers/clean-css).
-
-#### Parameters
-
-##### files ```object```
-
-This defines what files this task will process and should contain key:value pairs.
-
-The key (destination) should be an unique filepath (supports [grunt.template](https://github.com/cowboy/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)).
-
-Note: When the value contains an array of multiple filepaths, the contents are concatenated in the order passed.
-
-#### Config Example
-
-``` javascript
-mincss: {
- compress: {
- files: {
- "path/to/output.css": ["path/to/input_one.css", "path/to/input_two.css"]
- }
- }
-}
-
-```
View
30 docs/requirejs.md
@@ -1,30 +0,0 @@
-## Optimize RequireJS projects using r.js
-> Contributed By: [Tim Branyen](/tbranyen) (@tbranyen)
-
-### Overview
-
-Inside your `grunt.js` file add a section named `requirejs`. This section specifies the options passed to [RequireJS Optimizer](http://requirejs.org/docs/optimization.html).
-
-#### Parameters
-
-##### options ```object```
-
-This controls how this task (and its helpers) operate and should contain key:value pairs, see options below.
-
-#### Options
-
-For a full list of possible options, [see the r.js example build file](https://github.com/jrburke/r.js/blob/master/build/example.build.js).
-
-#### Config Example
-
-``` javascript
-requirejs: {
- compile: {
- options: {
- baseUrl: "path/to/base",
- mainConfigFile: "path/to/config.js",
- out: "path/to/optimized.js"
- }
- }
-}
-```
View
49 docs/stylus.md
@@ -1,49 +0,0 @@
-## Compile Stylus files to CSS
-> Contributed By: [Eric Woroshow](/errcw) (@errcw)
-
-### Overview
-
-Inside your `grunt.js` file add a section named `stylus`. This section specifies the files to compile and the options passed to [stylus](http://learnboost.github.com/stylus/).
-
-This task comes preloaded with [nib](http://visionmedia.github.com/nib/).
-
-#### Parameters
-
-##### files ```object```
-
-This defines what files this task will process and should contain key:value pairs.
-
-The key (destination) should be an unique filepath (supports [grunt.template](https://github.com/cowboy/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)).
-
-Note: When the value contains an array of multiple filepaths, the contents are concatenated in the order passed.
-
-##### options ```object```
-
-This controls how this task (and its helpers) operate and should contain key:value pairs, see options below.
-
-#### Options
-
-##### compress ```boolean```
-
-This specifies if we should compress the compiled css.
-
-##### paths ```string|array```
-
-This specifies directories to scan for @import directives when parsing.
-
-#### Config Example
-
-``` javascript
-stylus: {
- compile: {
- options: {
- compress: true,
- paths: ['path/to/import', 'another/to/import']
- },
- files: {
- 'path/to/result.css': 'path/to/source.styl',
- 'path/to/another.css': ['path/to/sources/*.styl', 'path/to/more/*.style'],
- }
- }
-},
-```
View
41 docs/yuidoc.md
@@ -1,41 +0,0 @@
-## Compile YUIDoc Documentation
-> Contributed By: [George Pantazis](/gcpantazis) (@gcpantazis)
-
-### Overview
-
-Inside your `grunt.js` file add a section named `yuidoc`. [Visit the YUIDoc project home](http://yui.github.com/yuidoc/) for more information on YUIDocs and commenting syntax.
-
-#### Parameters
-
-##### options ```object```
-
-This controls how this task operates and should contain key:value pairs, see options below.
-
-#### Options
-
-Options correlate to [YUIDoc config objects](http://yui.github.com/yuidoc/args/index.html).
-
-##### paths (required) ```string|array```
-
-What directory should be scanned to generate doc data.
-
-##### outdir (required) ```string```
-
-Where to save the documentation.
-
-#### Config Example
-
-``` javascript
-yuidoc: {
- compile: {
- "name": "Project Name",
- "description": "Project Description",
- "version": "1.0.2",
- "url": "http://projecturl.com/",
- options: {
- paths: "path/to/source/code/",
- outdir: "where/to/save/docs/"
- }
- }
-}
-```
View
28 grunt.js
@@ -1,28 +0,0 @@
-module.exports = function(grunt) {
- "use strict";
-
- grunt.initConfig({
- lint: {
- all: ["grunt.js", "tasks/*.js"]
- },
- jshint: {
- options: {
- curly: true,
- eqeqeq: true,
- immed: true,
- latedef: true,
- newcap: true,
- noarg: true,
- sub: true,
- undef: true,
- boss: true,
- eqnull: true,
- node: true,
- es5: true
- }
- }
- });
-
- grunt.registerTask("default", "lint");
- grunt.loadTasks("tasks");
-};
View
63 package.json
@@ -1,76 +1,43 @@
{
"name": "grunt-contrib",
"description": "A collection of common grunt tasks.",
- "version": "0.1.8pre",
+ "version": "0.2.0",
"homepage": "https://github.com/gruntjs/grunt-contrib",
-
"author": {
"name": "\"Cowboy\" Ben Alman and contributors",
"url": "http://gruntjs.com/"
},
-
"repository": {
"type": "git",
"url": "git://github.com/gruntjs/grunt-contrib.git"
},
-
"bugs": {
"url": "https://github.com/gruntjs/grunt-contrib/issues"
},
-
"licenses": [
{
"type": "MIT",
"url": "https://github.com/gruntjs/grunt-contrib/blob/master/LICENSE-MIT"
}
],
-
- "main": "grunt.js",
- "bin": "bin/grunt-contrib",
-
"engines": {
"node": "*"
},
-
- "scripts": {
- "test": "grunt --base ./test/ --config ./test/grunt.js"
- },
-
"dependencies": {
- "grunt": "~0.3.12",
-
- "clean-css": "~0.4.1",
-
- "coffee-script": "~1.3.3",
-
- "handlebars": "~1.0.4",
-
- "jade": "~0.27.2",
-
- "less": "~1.3.0",
-
- "requirejs": "~2.0.6",
-
- "rimraf": "~2.0.2",
-
- "stylus": "~0.29.0",
- "nib": "~0.8.1",
-
- "tar": "~0.1.13",
- "fstream": "~0.1.18",
-
- "underscore": "~1.3.3",
-
- "yuidocjs": "~0.3.14",
-
- "zipstream": "~0.2.1"
- },
-
- "devDependencies": {
- "grunt": "~0.3.12"
+ "grunt-contrib-clean": "~0.2.0",
+ "grunt-contrib-coffee": "~0.2.0",
+ "grunt-contrib-compress": "~0.2.0",
+ "grunt-contrib-copy": "~0.2.0",
+ "grunt-contrib-handlebars": "~0.2.0",
+ "grunt-contrib-jade": "~0.2.0",
+ "grunt-contrib-jst": "~0.2.0",
+ "grunt-contrib-less": "~0.2.0",
+ "grunt-contrib-mincss": "~0.2.0",
+ "grunt-contrib-requirejs": "~0.2.0",
+ "grunt-contrib-stylus": "~0.2.0",
+ "grunt-contrib-yuidoc": "~0.2.0"
},
-
"keywords": [
- "gruntplugin"
+ "gruntcollection"
]
-}
+}
View
37 tasks/bump.js
@@ -1,37 +0,0 @@
-/**
- * Task: bump
- * Description: Increase version number.
- * Dependencies: none
- * Contributor: @vojtajina
- */
-
-module.exports = function(grunt) {
- "use strict";
-
- grunt.registerTask("bump", "Increment version number", function(versionType) {
- var pkg = grunt.file.readJSON("package.json");
-
- pkg.version = grunt.helper("bump_version", pkg.version, versionType || "patch");
-
- grunt.file.write("package.json", JSON.stringify(pkg, null, " "));
- grunt.log.ok("Version bumped to " + pkg.version);
- });
-
-
- grunt.registerHelper("bump_version", function(version, versionType) {
- var type = {
- patch: 2,
- minor: 1,
- major: 0
- };
-
- var parts = version.split(".");
- var idx = type[versionType || "patch"];
-
- parts[idx] = parseInt(parts[idx], 10) + 1;
- while(++idx < parts.length) {
- parts[idx] = 0;
- }
- return parts.join(".");
- });
-};
View
35 tasks/clean.js
@@ -1,35 +0,0 @@
-/**
- * Task: clean
- * Description: Clear files and folders.
- * Dependencies: rimraf
- * Contributor: @tbranyen
- */
-
-module.exports = function(grunt) {
- "use strict";
-
- grunt.registerMultiTask("clean", "Clear files and folders", function() {
- var options = grunt.helper("options", this);
-
- grunt.verbose.writeflags(options, "Options");
-
- var paths = grunt.file.expand(this.file.src);
-
- paths.forEach(function(path) {
- grunt.helper("clean", path);
- });
- });
-
- grunt.registerHelper("clean", function(path) {
- grunt.log.write('Cleaning "' + path + '"...');
-
- try {
- require("rimraf").sync(path);
- grunt.log.ok();
- } catch (e) {
- grunt.log.error();
- grunt.verbose.error(e);
- grunt.fail.warn("Clean operation failed.");
- }
- });
-};
View
59 tasks/coffee.js
@@ -1,59 +0,0 @@
-/**
- * Task: coffee
- * Description: Compile CoffeeScript files into JavaScript
- * Dependencies: coffee-script
- * Contributor: @errcw
- */
-
-module.exports = function(grunt) {
- "use strict";
-
- // TODO: ditch this when grunt v0.4 is released
- grunt.util = grunt.util || grunt.utils;
-
- var _ = grunt.util._;
-
- grunt.registerMultiTask("coffee", "Compile CoffeeScript files into JavaScript", function() {
- var options = grunt.helper("options", this);
-
- grunt.verbose.writeflags(options, "Options");
-
- // TODO: ditch this when grunt v0.4 is released
- this.files = this.files || grunt.helper("normalizeMultiTaskFiles", this.data, this.target);
-
- var srcFiles;
- var taskOutput;
- var sourceCode;
- var sourceCompiled;
- var helperOptions;
-
- this.files.forEach(function(file) {
- srcFiles = grunt.file.expandFiles(file.src);
-
- taskOutput = [];
-
- srcFiles.forEach(function(srcFile) {
- helperOptions = _.extend({filename: srcFile}, options);
- sourceCode = grunt.file.read(srcFile);
-
- sourceCompiled = grunt.helper("coffee", sourceCode, helperOptions);
-
- taskOutput.push(sourceCompiled);
- });
-
- if (taskOutput.length > 0) {
- grunt.file.write(file.dest, taskOutput.join("\n"));
- grunt.log.writeln("File '" + file.dest + "' created.");
- }
- });
- });
-
- grunt.registerHelper("coffee", function(coffeescript, options) {
- try {
- return require("coffee-script").compile(coffeescript, options);
- } catch (e) {
- grunt.log.error(e);
- grunt.fail.warn("CoffeeScript failed to compile.");
- }
- });
-};
View
232 tasks/compress.js
@@ -1,232 +0,0 @@
-/**
- * Task: compress
- * Description: Compress files
- * Dependencies: zipstream / tar / fstream
- * Contributor: @ctalkington
- */
-
-module.exports = function(grunt) {
- "use strict";
-
- var fs = require("fs");
- var path = require("path");
-
- // TODO: ditch this when grunt v0.4 is released
- grunt.file.exists = grunt.file.exists || fs.existsSync || path.existsSync;
-
- // TODO: ditch this when grunt v0.4 is released
- grunt.util = grunt.util || grunt.utils;
-
- var _ = grunt.util._;
- var async = grunt.util.async;
-
- var getSize = function(filename) {
- try {
- return fs.statSync(filename).size;
- } catch (e) {
- return 0;
- }
- };
-
- var findBasePath = function(srcFiles) {
- var basePaths = [];
- var dirName;
-
- srcFiles.forEach(function(srcFile) {
- dirName = path.dirname(srcFile);
- dirName = path.normalize(dirName);
-
- basePaths.push(dirName.split(path.sep));
- });
-
- basePaths = _.intersection.apply([], basePaths);
-
- return path.join.apply(path, basePaths);
- };
-
- var tempCopy = function(srcFiles, tempDir, options) {
- var newFiles = [];
- var newMeta = {};
-
- var filename;
- var relative;
- var destPath;
-
- var basePath = options.basePath || findBasePath(srcFiles);
-
- srcFiles.forEach(function(srcFile) {
- filename = path.basename(srcFile);
- relative = path.dirname(srcFile);
- relative = path.normalize(relative);
-
- if (options.flatten) {
- relative = "";
- } else if (basePath && basePath.length > 1) {
- relative = _(relative).chain().strRight(basePath).trim(path.sep).value();
- }
-
- // make paths outside grunts working dir relative
- relative = relative.replace(/\.\.(\/|\\)/g, "");
-
- destPath = path.join(tempDir, relative, filename);
-
- newFiles.push(destPath);
- newMeta[destPath] = {name: path.join(relative, filename)};
-
- grunt.verbose.writeln("Adding " + srcFile + " to temporary structure.");
- grunt.file.copy(srcFile, destPath);
- });
-
- return [newFiles, newMeta];
- };
-
- grunt.registerMultiTask("compress", "Compress files.", function() {
- var options = grunt.helper("options", this, {
- mode: null,
- basePath: false,
- flatten: false,
- level: 1
- });
-
- // TODO: ditch this when grunt v0.4 is released
- this.files = this.files || grunt.helper("normalizeMultiTaskFiles", this.data, this.target);
-
- var supported = ["zip", "tar", "tgz", "gzip"];
- var helper = options.mode + "Helper";
- var done = this.async();
-
-
- if (options.basePath) {
- options.basePath = path.normalize(options.basePath);
- options.basePath = _(options.basePath).trim(path.sep);
- }
-
- grunt.verbose.writeflags(options, "Options");
-
- if (options.mode === "tgz") {
- helper = "tarHelper";
- }
-
- if (_.include(supported, options.mode) === false) {
- grunt.log.error("Mode " + options.mode + " not supported.");
- done();
- return;
- }
-
- var srcFiles;
- var destDir;
-
- async.forEachSeries(this.files, function(file, next) {
- srcFiles = grunt.file.expandFiles(file.src);
- destDir = path.dirname(file.dest);
-
- if (options.mode === "gzip" && srcFiles.length > 1) {
- grunt.fail.warn("Cannot specify multiple input files for gzip compression.");
- srcFiles = srcFiles[0];
- }
-
- if (grunt.file.exists(destDir) === false) {
- grunt.file.mkdir(destDir);
- }
-
- grunt.helper(helper, srcFiles, file.dest, options, function(written) {
- grunt.log.writeln('File "' + file.dest + '" created (' + written + ' bytes written).');
- next();
- });
-
- }, function() {
- done();
- });
- });
-
- grunt.registerHelper("zipHelper", function(srcFiles, dest, options, callback) {
- var zip = require("zipstream").createZip(options);
-
- var destDir = path.dirname(dest);
- var tempDir = path.join(destDir, "zip_" + (new Date()).getTime());
-
- var copyResult = tempCopy(srcFiles, tempDir, options);
-
- var zipFiles = _.uniq(copyResult[0]);
- var zipMeta = copyResult[1];
-
- zip.pipe(fs.createWriteStream(dest));
-
- var srcFile;
-
- function addFile() {
- if (!zipFiles.length) {
- zip.finalize(function(written) {
- grunt.helper("clean", tempDir);
- callback(written);
- });
- return;
- }
-
- srcFile = zipFiles.shift();
-
- zip.addFile(fs.createReadStream(srcFile), zipMeta[srcFile], addFile);
- }
-
- addFile();
-
- // TODO: node-zipstream v0.2.1 has issues that prevents this from working atm!
- zip.on("error", function(e) {
- grunt.log.error(e);
- grunt.fail.warn("zipHelper failed.");
- });
- });
-
- grunt.registerHelper("tarHelper", function(srcFiles, dest, options, callback) {
- var fstream = require("fstream");
- var tar = require("tar");
- var zlib = require("zlib");
-
- var destDir = path.dirname(dest);
- var destFile = path.basename(dest);
- var destFileExt = path.extname(destFile);
- var tempDir = path.join(destDir, "tar_" + (new Date()).getTime());
- var tarDir = _(destFile).strLeftBack(destFileExt);
-
- var tarProcess;
-
- tarDir = path.join(tempDir, tarDir);
-
- tempCopy(srcFiles, tarDir, options);
-
- var reader = fstream.Reader({path: tarDir, type: "Directory"});
- var packer = tar.Pack();
- var gzipper = zlib.createGzip();
- var writer = fstream.Writer(dest);
-
- if (options.mode === "tgz") {
- tarProcess = reader.pipe(packer).pipe(gzipper).pipe(writer);
- } else {
- tarProcess = reader.pipe(packer).pipe(writer);
- }
-
- tarProcess.on("error", function(e) {
- grunt.log.error(e);
- grunt.fail.warn("tarHelper failed.");
- });
-
- tarProcess.on("close", function() {
- grunt.helper("clean", tempDir);
- callback(getSize(dest));
- });
- });
-
- grunt.registerHelper("gzipHelper", function(file, dest, options, callback) {
- var zlib = require("zlib");
-
- zlib.gzip(grunt.file.read(file), function(e, result) {
- if (!e) {
- grunt.file.write(dest, result);
- callback(result.length);
- } else {
- grunt.log.error(e);
- grunt.fail.warn("tarHelper failed.");
- }
- });
- });
-};
View
101 tasks/copy.js
@@ -1,101 +0,0 @@
-/**
- * Task: copy
- * Description: Copy files into another directory
- * Contributor: @ctalkington
- */
-
-module.exports = function(grunt) {
- "use strict";
-
- var path = require("path");
-
- // TODO: ditch this when grunt v0.4 is released
- grunt.util = grunt.util || grunt.utils;
-
- var _ = grunt.util._;
- var kindOf = grunt.util.kindOf;
-
- var findBasePath = function(srcFiles) {
- var basePaths = [];
- var dirName;
-
- srcFiles.forEach(function(srcFile) {
- dirName = path.dirname(srcFile);
- dirName = path.normalize(dirName);
-
- basePaths.push(dirName.split(path.sep));
- });
-
- basePaths = _.intersection.apply([], basePaths);
-
- return path.join.apply(path, basePaths);
- };
-
- grunt.registerMultiTask("copy", "Copy files into another directory.", function() {
- var options = grunt.helper("options", this, {
- basePath: false,
- flatten: false,
- processName: false,
- processContent: false,
- processContentExclude: [],
- minimatch: {}
- });
-
- // TODO: ditch this when grunt v0.4 is released
- this.files = this.files || grunt.helper("normalizeMultiTaskFiles", this.data, this.target);
-
- var copyOptions = {
- process: options.processContent,
- noProcess: options.processContentExclude
- };
-
- if (options.basePath) {
- options.basePath = path.normalize(options.basePath);
- options.basePath = _(options.basePath).trim(path.sep);
- }
-
- grunt.verbose.writeflags(options, "Options");
-
- var srcFiles;
-
- var basePath;
- var filename;
- var relative;
- var destFile;
-
- this.files.forEach(function(file) {
- file.dest = path.normalize(file.dest);
- srcFiles = grunt.file.expandFiles(options.minimatch, file.src);
-
- basePath = options.basePath || findBasePath(srcFiles);
-
- grunt.verbose.writeln("Base Path: " + basePath.cyan);
- grunt.verbose.or.write("Copying file(s)" + ' to "' + file.dest + '"...');
-
- srcFiles.forEach(function(srcFile) {
- srcFile = path.normalize(srcFile);
- filename = path.basename(srcFile);
- relative = path.dirname(srcFile);
-
- if (options.flatten) {
- relative = "";
- } else if (basePath && basePath.length > 1) {
- relative = _(relative).chain().strRight(basePath).trim(path.sep).value();
- }
-
- if (options.processName && kindOf(options.processName) === "function") {
- filename = options.processName(filename);
- }
-
- // make paths outside grunts working dir relative
- relative = relative.replace(/\.\.(\/|\\)/g, "");
-
- destFile = path.join(file.dest, relative, filename);
-
- grunt.file.copy(srcFile, destFile, copyOptions);
- });
-
- grunt.verbose.or.ok();
- });
- });
-};
View
102 tasks/handlebars.js
@@ -1,102 +0,0 @@
-/**
- * Task: handlebars
- * Description: Compile handlebars templates to JST file
- * Dependencies: handlebars
- * Contributor: @tbranyen
- */
-
-module.exports = function(grunt) {
- "use strict";
-
- // TODO: ditch this when grunt v0.4 is released
- grunt.util = grunt.util || grunt.utils;
-
- var _ = grunt.util._;
-
- grunt.registerMultiTask("handlebars", "Register handlebars partials and then Compile handlebars templates to JST file", function() {
- var options = grunt.helper("options", this, {namespace: "JST"});
-
- grunt.verbose.writeflags(options, "Options");
-
- // TODO: ditch this when grunt v0.4 is released
- this.files = this.files || grunt.helper("normalizeMultiTaskFiles", this.data, this.target);
-
- var srcFiles;
- var partialFiles;
- var taskOutput = [];
- var sourceCode;
- var sourceCompiled;
- var expandedFiles;
-
- var helperNamespace = "this['" + options.namespace + "']";
- var isPartial = options.partialRegex || /^_/;
-
- var defaultProcessPartialName = function(filePath) {
- var pieces = _.last(filePath.split("/")).split(".");
- var name = _(pieces).without(_.last(pieces)).join("."); // strips file extension
- return name.substr(1, name.length); // strips leading _ character
- };
-
- var preProcessWithHelper = function(files, helper, output) {
- files.forEach(function(srcFile) {
- sourceCode = grunt.file.read(srcFile);
-
- // non-partials
- if (helper === "handlebars" && options.processName && _.isFunction(options.processName)) {
- srcFile = options.processName(srcFile);
- }
-
- // partials
- if (helper === "handlebars-partial" && options.processPartialName && _.isFunction(options.processPartialName)) {
- srcFile = options.processPartialName(srcFile);
- } else if (helper === "handlebars-partial") {
- srcFile = defaultProcessPartialName(srcFile);
- }
-
- sourceCompiled = grunt.helper(helper, sourceCode, srcFile, helperNamespace);
- output.push(sourceCompiled);
- });
- };
-
- this.files.forEach(function(file) {
- expandedFiles = grunt.file.expandFiles(file.src);
-
- srcFiles = _.filter(expandedFiles, function(f) {
- return !isPartial.test(_.last(f.split("/")));
- });
-
- partialFiles = _.filter(expandedFiles, function(f) {
- return isPartial.test(_.last(f.split("/")));
- });
-
- taskOutput.push(helperNamespace + " = " + helperNamespace + " || {};");
-
- preProcessWithHelper(partialFiles, "handlebars-partial", taskOutput);
- preProcessWithHelper(srcFiles, "handlebars", taskOutput);
-
- if (taskOutput.length > 0) {
- grunt.file.write(file.dest, taskOutput.join("\n\n"));
- grunt.log.writeln("File '" + file.dest + "' created.");
- }
- });
- });
-
- grunt.registerHelper("handlebars-partial", function(source, filepath, namespace) {
- try {
- return "Handlebars.registerPartial('" + filepath + "', " + "Handlebars.template(" + require("handlebars").precompile(source) + "));";
- } catch (e) {
- grunt.log.error(e);
- grunt.fail.warn("Handlebars failed to compile partial.");
- }
- });
-
- grunt.registerHelper("handlebars", function(source, filepath, namespace) {
- try {
- var output = "Handlebars.template(" + require("handlebars").precompile(source) + ");";
- return namespace + "['" + filepath + "'] = " + output;
- } catch (e) {
- grunt.log.error(e);
- grunt.fail.warn("Handlebars failed to compile.");
- }
- });
-};
View
72 tasks/helpers.js
@@ -1,72 +0,0 @@
-/**
- * Grunt Contrib Helpers
- * Description: help make things consistent across tasks.
- * Contributor: @tkellen
- */
-
-module.exports = function(grunt) {
- "use strict";
-
- // TODO: ditch this when grunt v0.4 is released
- grunt.util = grunt.util || grunt.utils;
-
- // Helper for consistent options key access across contrib tasks.
- grunt.registerHelper("options", function(data, defaults) {
- var _ = grunt.util._;
- var namespace = data.nameArgs.split(":");
- var task = grunt.config(_.flatten([namespace, "options"]));
- var global_subtask = namespace.length > 1 ? grunt.config(_.flatten(["options", namespace])) : {};
- var global = grunt.config(["options", namespace[0]]);
-
- return _.defaults({}, task, global_subtask, global, defaults || {});
- });
-
- // TODO: ditch this when grunt v0.4 is released
- // Temporary helper for normalizing files object
- grunt.registerHelper("normalizeMultiTaskFiles", function(data, target) {
- var prop, obj;
- var files = [];
- if (grunt.util.kindOf(data) === 'object') {
- if ('src' in data || 'dest' in data) {
- obj = {};
- if ('src' in data) { obj.src = data.src; }
- if ('dest' in data) { obj.dest = data.dest; }
- files.push(obj);
- } else if (grunt.util.kindOf(data.files) === 'object') {
- for (prop in data.files) {
- files.push({src: data.files[prop], dest: prop});
- }
- } else if (Array.isArray(data.files)) {
- data.files.forEach(function(obj) {
- var prop;
- if ('src' in obj || 'dest' in obj) {
- files.push(obj);
- } else {
- for (prop in obj) {
- files.push({src: obj[prop], dest: prop});
- }
- }
- });
- }
- } else {
- files.push({src: data, dest: target});
- }
-
- // Process each normalized file object as a template.
- files.forEach(function(obj) {
- // Process src as a template (recursively, if necessary).
- if ('src' in obj) {
- obj.src = grunt.util.recurse(obj.src, function(src) {
- if (typeof src !== 'string') { return src; }
- return grunt.template.process(src);
- });
- }
- if ('dest' in obj) {
- // Process dest as a template.
- obj.dest = grunt.template.process(obj.dest);
- }
- });
-
- return files;
- });
-};
View
68 tasks/jade.js
@@ -1,68 +0,0 @@
-/**
- * Task: jade
- * Description: Compile Jade templates to HTML
- * Dependencies: jade
- * Contributor: @errcw
- */
-
-module.exports = function(grunt) {
- "use strict";
-
- // TODO: ditch this when grunt v0.4 is released
- grunt.util = grunt.util || grunt.utils;
-
- var _ = grunt.util._;
- var kindOf = grunt.util.kindOf;
-
- grunt.registerMultiTask("jade", "Compile Jade templates into HTML.", function() {
- var options = grunt.helper("options", this, {data: {}});
-
- grunt.verbose.writeflags(options, "Options");
-
- // TODO: ditch this when grunt v0.4 is released
- this.files = this.files || grunt.helper("normalizeMultiTaskFiles", this.data, this.target);
-
- var helperData = options.data;
-
- _.each(helperData, function(value, key) {
- if (kindOf(value) === "string") {
- helperData[key] = grunt.template.process(value);
- }
- });
-
- var srcFiles;
- var taskOutput;
- var sourceCode;
- var sourceCompiled;
- var helperOptions;
-
- this.files.forEach(function(file) {
- srcFiles = grunt.file.expandFiles(file.src);
-
- taskOutput = [];
-
- srcFiles.forEach(function(srcFile) {
- helperOptions = _.extend({filename: srcFile}, options);
- sourceCode = grunt.file.read(srcFile);
-
- sourceCompiled = grunt.helper("jade", sourceCode, helperOptions, helperData);
-
- taskOutput.push(sourceCompiled);
- });
-
- if (taskOutput.length > 0) {
- grunt.file.write(file.dest, taskOutput.join("\n\n"));
- grunt.log.writeln("File '" + file.dest + "' created.");
- }
- });
- });
-
- grunt.registerHelper("jade", function(src, options, data) {
- try {
- return require("jade").compile(src, options)(data);
- } catch (e) {
- grunt.log.error(e);
- grunt.fail.warn("Jade failed to compile.");
- }
- });
-};
View
57 tasks/jst.js
@@ -1,57 +0,0 @@
-/**
- * Task: jst
- * Description: Compile underscore templates to JST file
- * Dependencies: underscore
- * Contributor: @tbranyen
- */
-
-module.exports = function(grunt) {
- "use strict";
-
- var _ = require("underscore");
-
- grunt.registerMultiTask("jst", "Compile underscore templates to JST file", function() {
- var options = grunt.helper("options", this, {namespace: "JST", templateSettings: {}});
-
- grunt.verbose.writeflags(options, "Options");
-
- // TODO: ditch this when grunt v0.4 is released
- this.files = this.files || grunt.helper("normalizeMultiTaskFiles", this.data, this.target);
-
- var srcFiles;
- var taskOutput;
- var sourceCode;
- var sourceCompiled;
-
- var helperNamespace = "this['" + options.namespace + "']";
-
- this.files.forEach(function(file) {
- srcFiles = grunt.file.expandFiles(file.src);
-
- taskOutput = [];
- taskOutput.push(helperNamespace + " = " + helperNamespace + " || {};");
-
- srcFiles.forEach(function(srcFile) {
- sourceCode = grunt.file.read(srcFile);
-
- sourceCompiled = grunt.helper("jst", sourceCode, srcFile, helperNamespace, options.templateSettings);
-
- taskOutput.push(sourceCompiled);
- });
-
- if (taskOutput.length > 0) {
- grunt.file.write(file.dest, taskOutput.join("\n\n"));
- grunt.log.writeln("File '" + file.dest + "' created.");
- }
- });
- });
-
- grunt.registerHelper("jst", function(source, filepath, namespace, templateSettings) {
- try {
- return namespace + "['" + filepath + "'] = " + _.template(source, false, templateSettings).source + ";";
- } catch (e) {
- grunt.log.error(e);
- grunt.fail.warn("JST failed to compile.");
- }
- });
-};
View
73 tasks/less.js
@@ -1,73 +0,0 @@
-/**
- * Task: less
- * Description: Compile LESS files to CSS
- * Dependencies: less
- * Contributor: @tkellen
- */
-
-module.exports = function(grunt) {
- "use strict";
-
- // TODO: ditch this when grunt v0.4 is released
- grunt.util = grunt.util || grunt.utils;
-
- var _ = grunt.util._;
- var async = grunt.util.async;
-
- var lessError = function(e) {
- var pos = '[' + 'L' + e.line + ':' + ('C' + e.column) + ']';
- grunt.log.error(e.filename + ': ' + pos + ' ' + e.message);
- grunt.fail.warn("Error compiling LESS.", 1);
- };
-
- grunt.registerMultiTask("less", "Compile LESS files to CSS", function() {
- var options = grunt.helper("options", this);
-
- grunt.verbose.writeflags(options, "Options");
-
- // TODO: ditch this when grunt v0.4 is released
- this.files = this.files || grunt.helper("normalizeMultiTaskFiles", this.data, this.target);
-
- var done = this.async();
-
- var srcFiles;
- var sourceCode;
- var helperOptions;
-
- async.forEachSeries(this.files, function(file, next) {
- srcFiles = grunt.file.expandFiles(file.src);
-
- async.concatSeries(srcFiles, function(srcFile, nextConcat) {
- helperOptions = _.extend({filename: srcFile}, options);
- sourceCode = grunt.file.read(srcFile);
-
- grunt.helper("less", sourceCode, helperOptions, function(css) {
- nextConcat(null, css);
- });
- }, function(err, css) {
- grunt.file.write(file.dest, css.join("\n") || "");
- grunt.log.writeln("File '" + file.dest + "' created.");
-
- next();
- });
-
- }, function() {
- done();
- });
- });
-
- grunt.registerHelper("less", function(source, options, callback) {
- require("less").Parser(options).parse(source, function(parse_error, tree) {
- if (parse_error) {
- lessError(parse_error);
- }
-
- try {
- var css = tree.toCSS();
- callback(css);
- } catch (e) {
- lessError(e);
- }
- });
- });
-};
View
44 tasks/mincss.js
@@ -1,44 +0,0 @@
-/**
- * Task: mincss
- * Description: Minify CSS files
- * Dependencies: clean-css
- * Contributor: @tbranyen
- */
-
-module.exports = function(grunt) {
- "use strict";
-
- grunt.registerMultiTask("mincss", "Minify CSS files", function() {
- var options = grunt.helper("options", this);
-
- grunt.verbose.writeflags(options, "Options");
-
- // TODO: ditch this when grunt v0.4 is released
- this.files = this.files || grunt.helper("normalizeMultiTaskFiles", this.data, this.target);
-
- var srcFiles;
- var taskOutput;
- var sourceCode;
-
- this.files.forEach(function(file) {
- srcFiles = grunt.file.expandFiles(file.src);
- sourceCode = grunt.helper("concat", srcFiles);
- taskOutput = grunt.helper("mincss", sourceCode);
-
- if (taskOutput.length > 0) {
- grunt.file.write(file.dest, taskOutput);
- grunt.log.writeln("File '" + file.dest + "' created.");
- grunt.helper('min_max_info', taskOutput, sourceCode);
- }
- });
- });
-
- grunt.registerHelper("mincss", function(source) {
- try {
- return require("clean-css").process(source);
- } catch (e) {
- grunt.log.error(e);
- grunt.fail.warn("css minification failed.");
- }
- });
-};
View
45 tasks/requirejs.js
@@ -1,45 +0,0 @@
-/**
- * Task: RequireJS
- * Description: Optimize RequireJS projects using r.js
- * Dependencies: requireJS
- * Contributor: @tbranyen
- */
-
-module.exports = function(grunt) {
- "use strict";
-
- // TODO: ditch this when grunt v0.4 is released
- grunt.util = grunt.util || grunt.utils;
-
- var _ = grunt.util._;
- var kindOf = grunt.util.kindOf;
-
- var requirejs = require("requirejs");
-
- // TODO: extend this to send build log to grunt.log.ok / grunt.log.error
- // by overriding the r.js logger (or submit issue to r.js to expand logging support)
- requirejs.define("node/print", [], function() {
- return function print(msg) {
- if (msg.substring(0, 5) === "Error") {
- grunt.log.errorlns(msg);
- grunt.fail.warn("RequireJS failed.");
- } else {
- grunt.log.oklns(msg);
- }
- };
- });
-
- grunt.registerMultiTask("requirejs", "Build a RequireJS project.", function() {
- var options = grunt.helper("options", this, {logLevel: 0});
-
- _.each(options, function(value, key) {
- if (kindOf(value) === "string") {
- options[key] = grunt.template.process(value);
- }
- });
-
- grunt.verbose.writeflags(options, "Options");
-
- requirejs.optimize(options);
- });
-};
View
73 tasks/stylus.js
@@ -1,73 +0,0 @@
-/**
- * Task: stylus
- * Description: Compile Stylus files into CSS
- * Dependencies: stylus
- * Contributor: @errcw
- */
-
-module.exports = function(grunt) {
- "use strict";
-
- // TODO: ditch this when grunt v0.4 is released
- grunt.util = grunt.util || grunt.utils;
-
- var _ = grunt.util._;
- var async = grunt.util.async;
-
- grunt.registerMultiTask("stylus", "Compile Stylus files into CSS", function() {
- var options = grunt.helper("options", this);
-
- grunt.verbose.writeflags(options, "Options");
-
- // TODO: ditch this when grunt v0.4 is released
- this.files = this.files || grunt.helper("normalizeMultiTaskFiles", this.data, this.target);
-
- var done = this.async();
-
- var srcFiles;
- var sourceCode;
- var helperOptions;
-
- async.forEachSeries(this.files, function(file, next) {
- srcFiles = grunt.file.expandFiles(file.src);
-
- async.concatSeries(srcFiles, function(srcFile, nextConcat) {