Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 1 | 'use strict'; |
| 2 | |
| 3 | /** |
| 4 | * This file contains the variables used in other gulp files |
| 5 | * which defines tasks |
| 6 | * By design, we only put there very generic config values |
| 7 | * which are used in several places to keep good readability |
| 8 | * of the tasks |
| 9 | */ |
| 10 | |
| 11 | const path = require('path'); |
| 12 | const gutil = require('gulp-util'); |
| 13 | |
| 14 | /** |
| 15 | * The main paths of your project handle these with care |
| 16 | */ |
| 17 | exports.paths = { |
| 18 | src: 'src', |
| 19 | dist: 'dist', |
Matteo Scandolo | 43ffb67 | 2016-12-02 14:49:58 -0800 | [diff] [blame] | 20 | appConfig: 'conf/app', |
Matteo Scandolo | d819c92 | 2016-12-02 14:06:14 -0800 | [diff] [blame] | 21 | tmp: '.tmp', |
| 22 | e2e: 'e2e', |
| 23 | tasks: 'gulp_tasks' |
| 24 | }; |
| 25 | |
| 26 | exports.path = {}; |
| 27 | for (const pathName in exports.paths) { |
| 28 | if (exports.paths.hasOwnProperty(pathName)) { |
| 29 | exports.path[pathName] = function pathJoin() { |
| 30 | const pathValue = exports.paths[pathName]; |
| 31 | const funcArgs = Array.prototype.slice.call(arguments); |
| 32 | const joinArgs = [pathValue].concat(funcArgs); |
| 33 | return path.join.apply(this, joinArgs); |
| 34 | }; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Common implementation for an error handler of a Gulp plugin |
| 40 | */ |
| 41 | exports.errorHandler = function (title) { |
| 42 | return function (err) { |
| 43 | gutil.log(gutil.colors.red(`[${title}]`), err.toString()); |
| 44 | this.emit('end'); |
| 45 | }; |
| 46 | }; |