blob: 12e482e9d84be3c6536570119b97f3d46e3ff2ec [file] [log] [blame]
Matteo Scandolod819c922016-12-02 14:06:14 -08001'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
11const path = require('path');
12const gutil = require('gulp-util');
13
14/**
15 * The main paths of your project handle these with care
16 */
17exports.paths = {
18 src: 'src',
19 dist: 'dist',
20 tmp: '.tmp',
21 e2e: 'e2e',
22 tasks: 'gulp_tasks'
23};
24
25exports.path = {};
26for (const pathName in exports.paths) {
27 if (exports.paths.hasOwnProperty(pathName)) {
28 exports.path[pathName] = function pathJoin() {
29 const pathValue = exports.paths[pathName];
30 const funcArgs = Array.prototype.slice.call(arguments);
31 const joinArgs = [pathValue].concat(funcArgs);
32 return path.join.apply(this, joinArgs);
33 };
34 }
35}
36
37/**
38 * Common implementation for an error handler of a Gulp plugin
39 */
40exports.errorHandler = function (title) {
41 return function (err) {
42 gutil.log(gutil.colors.red(`[${title}]`), err.toString());
43 this.emit('end');
44 };
45};