Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating recipes to align with new docs #2305

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions docs/recipes/using-external-config-file.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Using external config file

Beneficial because it's keeping tasks DRY and config.json can be used by another task runner, like `grunt`.
Beneficial because it keeps tasks DRY and `config.json` can be used by another task runner, like `grunt`.

-

Expand Down Expand Up @@ -30,24 +30,22 @@ Beneficial because it's keeping tasks DRY and config.json can be used by another
###### `gulpfile.js`

```js
// npm install --save-dev gulp@next gulp-uglify merge-stream
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var merge = require('merge-stream');
// npm install --save-dev gulp gulp-uglify

var config = require('./config.json');
const { src, dest, parallel } = require('gulp');
const uglify = require('gulp-uglify');

function doStuff(cfg) {
return gulp.src(cfg.src)
const config = require('./config.json');

function test(cfg) {
return src(cfg.src)
.pipe(uglify())
.pipe(gulp.dest(cfg.dest));
.pipe(dest(cfg.dest));
}

gulp.task('dry', function() {
// return a stream to signal completion
return merge([
doStuff(config.desktop),
doStuff(config.mobile)
])
});
exports.default = function(cb) {
test(config.desktop),
test(config.mobile),
cb();
};
```
39 changes: 22 additions & 17 deletions docs/recipes/using-multiple-sources-in-one-task.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
# Using multiple sources in one task

```js
// npm install --save-dev gulp@next merge-stream
// npm install --save-dev gulp merge-stream

var gulp = require('gulp');
var merge = require('merge-stream');
const { src, dest } = require('gulp');
const merge = require('merge-stream');

gulp.task('test', function() {
var bootstrap = gulp.src('bootstrap/js/*.js')
.pipe(gulp.dest('public/bootstrap'));
function test() {
const bootstrap = src('bootstrap/js/**/*.js')
.pipe(dest('public/bootstrap'));

var jquery = gulp.src('jquery.cookie/jquery.cookie.js')
.pipe(gulp.dest('public/jquery'));
const jquery = src('jquery.cookie/jquery.cookie.js')
.pipe(dest('public/jquery'));

return merge(bootstrap, jquery);
});
}

exports.test = test;
```

`gulp.src` will emit files in the order they were added:
`src` will emit files in the order they were added:

```js
// npm install gulp@next gulp-concat
// npm install --save-dev gulp gulp-concat

var gulp = require('gulp');
var concat = require('gulp-concat');
const { src, dest } = require('gulp');
const concat = require('gulp-concat');

gulp.task('default', function() {
return gulp.src(['foo/*', 'bar/*'])
function test() {
return src(['foo/*', 'bar/*'])
.pipe(concat('result.txt'))
.pipe(gulp.dest('build'));
});
.pipe(dest('build'));
}

exports.default = test;
```