Skip to content

Commit

Permalink
A recipe for passing parameters from the command line
Browse files Browse the repository at this point in the history
  • Loading branch information
robrich committed Jan 13, 2014
1 parent 2c064bb commit 423b0c8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ See [the FAQ](FAQ.md) for the answers to commonly asked questions.
* [Working with multiple sources in one task](recipes/using-multiple-sources-in-one-task.md)
* [Mocha test runner with gulp](recipes/mocha-test-runner-with-gulp.md)
* [Rebuild only files that change](recipes/rebuild-only-files-that-change.md)
* [Pass parameters from the command line](recipes/pass-params-from-cli.md)
* [Using external config file](recipes/using-external-config-file.md)
* [Introduction to node.js streams](https://github.com/substack/stream-handbook)

Expand Down
27 changes: 27 additions & 0 deletions docs/recipes/pass-params-from-cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Pass parameters from the command line
## bonus: keeping those tasks DRY

---

`gulpfile.js`

```js
// npm install gulp gulp-if gulp-uglify
var gulp = require('gulp');
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');

var isProduction = gulp.env.type === 'production';

gulp.task('scripts', function () {
return gulp.src('**/*.js')
.pipe(gulpif(isProduction, uglify())) // only minify if production
.pipe(gulp.dest('dist'));
});
```

---

`cli`

`gulp scripts --type production`
2 changes: 1 addition & 1 deletion test/tasks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*jshint node:true */
/*global describe:false, it:false, beforeEach:false, afterEach:false */
/*global describe:false, it:false */
"use strict";

var gulp = require('../');
Expand Down

0 comments on commit 423b0c8

Please sign in to comment.