Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

rough in .4

  • Loading branch information...
commit 58aa6a4f8e242adb3287e4a6912880fe32e30df2 1 parent 5199019
@tkellen tkellen authored
View
14 .jshintrc
@@ -0,0 +1,14 @@
+{
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "sub": true,
+ "undef": true,
+ "boss": true,
+ "eqnull": true,
+ "node": true,
+ "es5": true
+}
View
73 CONTRIBUTING.md
@@ -0,0 +1,73 @@
+[Grunt homepage](http://gruntjs.com/) | [Documentation table of contents](https://github.com/gruntjs/grunt/blob/devel/docs/toc.md)
+
+# Contributing to grunt
+
+There are a number of grunt projects.
+
+* [grunt](https://github.com/gruntjs/grunt) - the main grunt project
+* [gruntjs.com](https://github.com/gruntjs/gruntjs.com) - the gruntjs.com website
+* [grunt-contrib collection](https://github.com/gruntjs/grunt-contrib) - a collection of all grunt "contrib" plugins
+
+In addition, each individual grunt-contrib plugin is a separate repository listed on the [gruntjs org homepage](https://github.com/gruntjs).
+
+## Filing issues
+If something isn't working like you think it should, please read the documentation first. If you'd like to chat with someone, [pop into IRC](#discussing-grunt) and ask your question there.
+
+The best way to ensure an issue gets addressed is to file it in the appropriate issues tracker.
+
+**If there's an issue with a specific grunt-contrib plugin:**
+Please file an issue on that plugin's issues tracker.
+
+**If you'd like to contribute a new plugin:**
+Please file an issue on the [grunt-contrib collection issues tracker](https://github.com/gruntjs/grunt-contrib/issues). We don't accept all plugins, but we'll certainly consider yours.
+
+**If there's an issue with the [website](http://gruntjs.com/):**
+Please file an issue on the [gruntjs.com website issues tracker](https://github.com/gruntjs/gruntjs.com/issues).
+
+**If there's an issue that isn't specific to any of the above:**
+Please file an issue on the [grunt issues tracker](https://github.com/gruntjs/grunt/issues).
+
+### Simplify the issue
+Try to [reduce your code](http://www.webkit.org/quality/reduction.html) to the bare minimum required to reproduce the issue. This makes it much easier (and much faster) to isolate and fix the issue.
+
+### Explain the issue
+If we can't reproduce the issue, we can't fix it. Please list the exact steps required to reproduce the issue. Include versions of your OS, Node.js, grunt, etc. Include relevant logs or sample code.
+
+## Discussing grunt
+Join the [freenode](http://freenode.net/) IRC #grunt channel. We've got a bot and everything.
+
+_No private messages, please._
+
+## Modifying grunt
+First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed.
+
+1. Fork and clone the repo.
+1. Check out the correct branch. Currently, grunt development happens in the `devel` branch.
+1. Run `npm install` to install all grunt dependencies.
+1. Run `npm link` to put the dev version of grunt in the system path (this is only needed for developing grunt, not for plugins or the website).
+1. Run `grunt` to grunt grunt.
+
+Assuming that you don't see any red, you're ready to go. Just be sure to run `grunt` after making any changes, to ensure that nothing breaks.
+
+### Submitting pull requests
+
+1. Create a new branch, please don't work in your `master` or `devel` branch directly.
+1. Add failing tests for the change you want to make. Run `grunt` to see the tests fail.
+1. Fix stuff.
+1. Run `grunt` to see if the tests pass. Repeat steps 2-4 until done.
+1. Update the documentation to reflect any changes.
+1. Push to your fork and submit a pull request.
+
+### Syntax
+
+* Two space indents. Don't use tabs anywhere. Use `\t` if you need a tab character in a string.
+* No trailing whitespace, except in markdown files where a linebreak must be forced.
+* Don't go overboard with the whitespace.
+* No more than [one assignment](http://benalman.com/news/2012/05/multiple-var-statements-javascript/) per `var` statement.
+* Delimit strings with single-quotes `'`, not double-quotes `"`.
+* Prefer `if` and `else` to ["clever"](http://programmers.stackexchange.com/a/25281) uses of `? :` conditional or `||`, `&&` logical operators.
+* Comments are great. Just put them _before_ the line of code, _not_ at the _end_ of the line.
+* **When in doubt, follow the conventions you see used in the source already.**
+
+### Reverting back to the "official" grunt
+If you've used `npm link` to put a dev version of grunt in the system path and, for some reason, need to revert back to the current official grunt release, just reinstall grunt globally with `npm install -g grunt`
View
46 grunt.js → Gruntfile.js
@@ -11,29 +11,14 @@ module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
- test_vars: {
- name: 'grunt-contrib-compress',
- version: '0.1.0'
- },
-
- lint: {
- all: ['grunt.js', 'tasks/*.js', '<config:nodeunit.tasks>']
- },
-
jshint: {
+ all: [
+ 'Gruntfile.js',
+ 'tasks/*.js',
+ '<%= nodeunit.tests %>'
+ ],
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
+ jshintrc: '.jshintrc'
}
},
@@ -42,6 +27,11 @@ module.exports = function(grunt) {
test: ['tmp']
},
+ test_vars: {
+ name: 'grunt-contrib-compress',
+ version: '0.1.0'
+ },
+
files: {
compress_test: 'test/fixtures/folder_one'
},
@@ -92,21 +82,23 @@ module.exports = function(grunt) {
// Unit tests.
nodeunit: {
- tasks: ['test/*_test.js']
+ tests: ['test/*_test.js']
}
});
// Actually load this plugin's task(s).
grunt.loadTasks('tasks');
- // The clean plugin helps in testing.
- grunt.loadNpmTasks('grunt-contrib-clean');
+ // These plugins provide necessary tasks.
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-contrib-nodeunit');
+ grunt.loadNpmTasks('grunt-contrib-internal');
// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
- grunt.renameTask('test', 'nodeunit');
- grunt.registerTask('test', 'clean compress nodeunit');
+ grunt.registerTask('test', ['nodeunit']);
// By default, lint and run all tests.
- grunt.registerTask('default', 'lint test');
+ grunt.registerTask('default', ['compress', 'test', 'build-contrib']);
+
};
View
97 README.md
@@ -2,63 +2,93 @@
> Compress files and folders.
+_Note that this plugin has not yet been released, and only works with the latest bleeding-edge, in-development version of grunt. See the [When will I be able to use in-development feature 'X'?](https://github.com/gruntjs/grunt/blob/devel/docs/faq.md#when-will-i-be-able-to-use-in-development-feature-x) FAQ entry for more information._
+
## Getting Started
-Install this grunt plugin next to your project's [grunt.js gruntfile][getting_started] with: `npm install grunt-contrib-compress`
+_If you haven't used [grunt][] before, be sure to check out the [Getting Started][] guide._
-Then add this line to your project's `grunt.js` gruntfile:
+From the same directory as your project's [Gruntfile][Getting Started] and [package.json][], install this plugin with the following command:
-```javascript
-grunt.loadNpmTasks('grunt-contrib-compress');
+```bash
+npm install grunt-contrib-compress --save-dev
```
-[grunt]: https://github.com/gruntjs/grunt
-[getting_started]: https://github.com/gruntjs/grunt/blob/master/docs/getting_started.md
+Once that's done, add this line to your project's Gruntfile:
-### Overview
+```js
+grunt.loadNpmTasks('grunt-contrib-compress');
+```
-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).
+If the plugin has been installed correctly, running `grunt --help` at the command line should list the newly-installed plugin's task or tasks. In addition, the plugin should be listed in package.json as a `devDependency`, which ensures that it will be installed whenever the `npm install` command is run.
-#### Parameters
+[grunt]: http://gruntjs.com/
+[Getting Started]: https://github.com/gruntjs/grunt/blob/devel/docs/getting_started.md
+[package.json]: https://npmjs.org/doc/json.html
-##### files ```object```
-This defines what files this task will compress and should contain key:value pairs.
+## The compress task
-The key (destination) should be an unique filepath (supports [grunt.template](https://github.com/gruntjs/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)).
+### Overview
-##### options ```object```
+In your project's Gruntfile, add a section named `compress` to the data object passed into `grunt.initConfig()`.
+
+```js
+grunt.initConfig({
+ compress: {
+ options: {
+ // Task-specific options go here.
+ },
+ your_target: {
+ // Target-specific file lists and/or options go here.
+ },
+ },
+})
+```
+
+Node Libraries Used:
+[zipstream](https://github.com/wellawaretech/node-zipstream) (for zip)
+[tar](https://github.com/isaacs/node-tar) (for tar/tgz)
+[zlib](http://nodejs.org/api/zlib.html#zlib_options) (for gzip).
+### Options
-This controls how this task operates and should contain key:value pairs, see options below.
+## files
+Type: `Object`
-#### Options
+This defines what files this task will compress and should contain key:value pairs.
-##### mode ```string```
+The key (destination) should be an unique filepath (supports [grunt.template](https://github.com/gruntjs/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)).
-This is used to define which mode to use, currently supports gzip, tar, tgz (tar gzip) and zip.
+## options.mode
+Type: `String`
-As of v0.3.0, this is now automatically detected per dest:src pair but can be overridden per target if desired.
+This is used to define which mode to use, currently supports `gzip`, `tar`, `tgz` (tar gzip) and `zip`.
-##### basePath ```string```
+Automatically detected per dest:src pair, but can be overridden per target if desired.
-This option adjusts internal filenames to be relative to provided path, within the resulting archive file.
+## options.basePath
+Type: `String`
-This has been automatically detected per dest:src pair for some time now but can be overridden per target if desired.
+Adjusts internal filenames to be relative to provided path, within the resulting archive file. Automatically detected per dest:src pair but can be overridden per target if desired.
-##### flatten ```boolean```
+## options.flatten
+Type: `Boolean`
+Default: false
-This option performs a flat copy that dumps all the files into the root of the destination file, overwriting files if they exist.
+Perform a flat copy that dumps all the files into the root of the destination file, overwriting files if they exist.
-##### level ```integer``` (zip only)
+## options.level (zip only)
+Type: `Integer`
+Default: 1
-This option sets the level of archive compression (defaults to 1).
+Sets the level of archive compression.
> Currently, gzip compression related options are not supported due to deficiencies in node's zlib library.
-##### rootDir ```string```
+## options.rootDir
+Type: `String`
This option allows the creation of a root folder to contain files within the resulting archive file.
-
-#### Config Example
+### Examples
``` javascript
compress: {
@@ -74,6 +104,15 @@ compress: {
}
```
+## Release History
+
+ * 2012-10-11 - v0.3.2 - Rename grunt-contrib-lib dep to grunt-lib-contrib.
+ * 2012-10-08 - v0.3.1 - replace zipstream package.
+ * 2012-09-23 - v0.3.0 - General cleanup. Options no longer accepted from global config key.
+ * 2012-09-17 - v0.2.2 - Test refactoring. No valid source check. Automatic mode detection.
+ * 2012-09-09 - v0.2.0 - Refactored from grunt-contrib into individual repo.
+
--
+Task submitted by <a href="http://christalkington.com/">Chris Talkington</a>.
-*Task submitted by [Chris Talkington](https://github.com/ctalkington).*
+*Generated on Thu Oct 18 2012 22:20:13.*
View
2  docs/examples.md → docs/compress-examples.md
@@ -1,3 +1,5 @@
+# Examples
+
``` javascript
compress: {
zip: {
View
39 docs/compress-options.md
@@ -0,0 +1,39 @@
+# Options
+
+## files
+Type: `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/gruntjs/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.mode
+Type: `String`
+
+This is used to define which mode to use, currently supports `gzip`, `tar`, `tgz` (tar gzip) and `zip`.
+
+Automatically detected per dest:src pair, but can be overridden per target if desired.
+
+## options.basePath
+Type: `String`
+
+Adjusts internal filenames to be relative to provided path, within the resulting archive file. Automatically detected per dest:src pair but can be overridden per target if desired.
+
+## options.flatten
+Type: `Boolean`
+Default: false
+
+Perform a flat copy that dumps all the files into the root of the destination file, overwriting files if they exist.
+
+## options.level (zip only)
+Type: `Integer`
+Default: 1
+
+Sets the level of archive compression.
+
+> Currently, gzip compression related options are not supported due to deficiencies in node's zlib library.
+
+## options.rootDir
+Type: `String`
+
+This option allows the creation of a root folder to contain files within the resulting archive file.
View
21 docs/compress-overview.md
@@ -0,0 +1,21 @@
+# Overview
+
+In your project's Gruntfile, add a section named `compress` to the data object passed into `grunt.initConfig()`.
+
+```js
+grunt.initConfig({
+ compress: {
+ options: {
+ // Task-specific options go here.
+ },
+ your_target: {
+ // Target-specific file lists and/or options go here.
+ },
+ },
+})
+```
+
+Node Libraries Used:
+[zipstream](https://github.com/wellawaretech/node-zipstream) (for zip)
+[tar](https://github.com/isaacs/node-tar) (for tar/tgz)
+[zlib](http://nodejs.org/api/zlib.html#zlib_options) (for gzip).
View
37 docs/options.md
@@ -1,37 +0,0 @@
-##### 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/gruntjs/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.
-
-As of v0.3.0, this is now automatically detected per dest:src pair but can be overridden per target if desired.
-
-##### basePath ```string```
-
-This option adjusts internal filenames to be relative to provided path, within the resulting archive file.
-
-This has been automatically detected per dest:src pair for some time now but can be overridden per target if desired.
-
-##### 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.
-
-##### rootDir ```string```
-
-This option allows the creation of a root folder to contain files within the resulting archive file.
View
4 docs/overview.md
@@ -1,4 +0,0 @@
-Node Libraries Used:
-[zipstream](https://github.com/wellawaretech/node-zipstream) (for zip)
-[tar](https://github.com/isaacs/node-tar) (for tar/tgz)
-[zlib](http://nodejs.org/api/zlib.html#zlib_options) (for gzip).
View
6 package.json
@@ -35,8 +35,10 @@
"grunt-lib-contrib": "~0.3.0"
},
"devDependencies": {
- "grunt": "~0.3.15",
- "grunt-contrib-clean": "~0.3.0"
+ "grunt-contrib-jshint": "0.1.0",
+ "grunt-contrib-nodeunit": "0.1.0",
+ "grunt-contrib-internal": "*",
+ "grunt": "~0.4.0a"
},
"keywords": [
"gruntplugin"
View
23 tasks/compress.js
@@ -6,23 +6,19 @@
* Licensed under the MIT license.
*/
+'use strict';
+
module.exports = function(grunt) {
- 'use strict';
var fs = require('fs');
var path = require('path');
var rimraf = require('rimraf');
-
- // 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 helpers = require('grunt-lib-contrib').init(grunt);
grunt.registerMultiTask('compress', 'Compress files.', function() {
- var options = helpers.options(this, {
+ var srcFiles, destDir, mode;
+ var done = this.async();
+ var options = this.options({
mode: null,
basePath: false,
flatten: false,
@@ -30,15 +26,10 @@ module.exports = function(grunt) {
rootDir: false
});
- // TODO: ditch this when grunt v0.4 is released
- this.files = this.files || helpers.normalizeMultiTaskFiles(this.data, this.target);
-
var supportedModes = ['zip', 'tar', 'tgz', 'gzip'];
var targetMode = options.mode;
delete options.mode;
- var done = this.async();
-
if (grunt.util.kindOf(options.rootDir) === 'string' && options.rootDir.length >= 1) {
options.rootDir = path.normalize(options.rootDir).split(path.sep)[0];
} else {
@@ -47,10 +38,6 @@ module.exports = function(grunt) {
grunt.verbose.writeflags(options, 'Options');
- var srcFiles;
- var destDir;
- var mode;
-
grunt.util.async.forEachSeries(this.files, function(file, next) {
srcFiles = grunt.file.expandFiles(file.src);
destDir = path.dirname(file.dest);
Please sign in to comment.
Something went wrong with that request. Please try again.