Skip to content

Commit

Permalink
v10.2.0 - Adapting the default task so that it works with Gulp v4. (#167
Browse files Browse the repository at this point in the history
)

* v10.2.0 - Adapting the default task so that it works with Gulp v4.

* v10.2.0 - Updated yarn.lock

* v10.2.0 - Updating package.json version.

* v10.2.0 - Updating readme.
  • Loading branch information
Sacha Zvetelman authored May 5, 2020
1 parent 75289e7 commit 1a5d100
Show file tree
Hide file tree
Showing 9 changed files with 1,083 additions and 903 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

v10.2.0
------------------------------
*May 5, 2020*

## Changed
- Adapted the `default` task so that it works with Gulp v4.


v10.1.0
------------------------------
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ Here is the outline of the configuration options, descriptions of each are below
],
jsDir,
lintPaths,
allowEmpty
usePackageVersion,
stripDebug
},
Expand Down Expand Up @@ -527,6 +528,13 @@ Will add a content hash to the JS and CSS filenames, generating a new filename i
By default, the task will lint all files within the `jsDir` directory.
- #### `allowEmpty`
Type: `boolean`
Default: `true`
When set to `true`, it will allow the globbing patterns not to return any files without failing. If set to `false`, no files will result in an exception.
- #### `usePackageVersion`
Expand Down
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const ConfigOptions = () => {
},
jsDir: 'js',
lintPaths: [],
allowEmpty: true,
usePackageVersion: false,
stripDebug
},
Expand Down
16 changes: 13 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable global-require */
/**
gulp-build-fozzie
===========
Expand All @@ -24,12 +25,21 @@ const build = (srcGulp, options) => {
pathBuilder.update(config);
}

// In gulp 4, tasks need to be included in a specific order, unless declared as functions.
// We require each of the files individually rather than the whole directory so we can decide on the order.
require('./tasks/clean.js');
require('./tasks/copy.js');
require('./tasks/css.js');
require('./tasks/images.js');
require('./tasks/javascript.js');
require('./tasks/logger-file.js');
require('./tasks/service-worker.js');
require('./tasks/default.js');
require('./tasks/watch.js');

// Assign existing gulp tasks so that they are not lost.
gulp.tasks = srcGulp.tasks;

// Require all tasks in /tasks, including subfolders
requireDir('./tasks', { recurse: true });

// Require dev tasks if running in development.
if (config.isDev) {
requireDir('./tasks-dev', { recurse: false });
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@justeat/gulp-build-fozzie",
"version": "10.1.0",
"version": "10.2.0",
"description": "Gulp build tasks for use across Fozzie modules",
"main": "index.js",
"contributors": [
Expand Down
19 changes: 10 additions & 9 deletions tasks/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ const config = require('../config');
* TODO: As this is legacy, this hasn't been done currently
*
*/
gulp.task('default', callback => {
gulp.series(
gulp.parallel('copy:fonts', 'images'),
gulp.series('css', 'scripts'),
'logger:createFile',
...(config.sw.isEnabled ? 'service-worker' : ''),
callback
);
});

gulp.task('default', gulp.series(
gulp.parallel('copy:fonts', 'images'),
gulp.series('css', 'scripts'),
'logger:createFile',
...(config.sw.isEnabled ? 'service-worker' : ''),
done => {
done();
}
));
2 changes: 1 addition & 1 deletion tasks/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const pathBuilder = require('../pathBuilder');
* Uses config rules to test for valid JS.
*
*/
gulp.task('scripts:lint', () => gulp.src([`${pathBuilder.jsSrcDir}/**/*.js`, ...config.js.lintPaths])
gulp.task('scripts:lint', () => gulp.src([`${pathBuilder.jsSrcDir}/**/*.js`, ...config.js.lintPaths], { allowEmpty: config.js.allowEmpty })
.pipe(cache('scripts-lint'))

// stops watch from breaking on error
Expand Down
2 changes: 1 addition & 1 deletion tasks/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const config = require('../config');
* Generates a service worker to pre-cache the assets defined in the config.
*
*/
gulp.task('service-worker:write', () => {
gulp.task('service-worker:write', async () => {
const runtimeCaching = config.sw.dynamicFileRegex.map(urlPattern => ({
urlPattern,
handler: config.sw.dynamicFileStrategy
Expand Down
Loading

0 comments on commit 1a5d100

Please sign in to comment.