Skip to content

Commit

Permalink
#1: code standards
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanfalkowski committed Mar 15, 2019
1 parent 2043d4e commit 72f54c6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
31 changes: 19 additions & 12 deletions gulp/error-formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,27 @@


// ==============================================
// Gulp Error Handler
// Gulp Error Formatter
// ==============================================

// An error handler that uses "pump" to keep errors from ending streams.
// An error formatter that uses Node "stream.pipeline" to keep errors from ending streams.
// Each plugin may have unique error objects, so the response is normalized.
//
// See: https://github.com/mikaelbr/gulp-notify/issues/81
// See: https://github.com/terinjokes/gulp-uglify/blob/master/docs/why-use-pump/README.md

var beeper = require('beeper');
var color = require('ansi-colors');
var minimist = require('minimist');
var notify = require('gulp-notify');

var beeper = require('beeper');
var color = require('ansi-colors');
var minimist = require('minimist');
var notify = require('gulp-notify');
var PluginError = require('plugin-error');

var arguments = minimist(process.argv.slice(2));
// ----------------------------------------------
// Arguments

var arguments = minimist(process.argv.slice(2));
var showProperties = (arguments['show-properties']) ? true : false;

// ----------------------------------------------
// Module

module.exports = function (error) {
if (typeof error !== 'undefined') {
// [log] Uncomment to show the full error object
Expand Down Expand Up @@ -72,7 +75,7 @@ module.exports = function (error) {
}

// ----------------------------------------------
// Fire Mac/Windows notification for error
// Show Mac/Windows notification

notify({
title: 'Failed Gulp — See Console',
Expand All @@ -82,10 +85,14 @@ module.exports = function (error) {

beeper(); // Fallback to system sound (for Windows).

// ----------------------------------------------
// Throw error

var customError = new PluginError(error.plugin, report.join(''), {
error: error,
showProperties: showProperties
});

throw customError;
}
};
20 changes: 11 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ var stylelint = require('gulp-stylelint');
var uglify = require('gulp-uglify');

// GravDept modules
var config = require('./gulp/config.js');
var config = require('./gulp/config');
var errorFormatter = require('./gulp/error-formatter');


// ==============================================
// Notifications
// Arguments
// ==============================================

// Run "gulp" without arguments for helpful dev notifications.
Expand Down Expand Up @@ -173,20 +174,21 @@ function lintJs () {
// ==============================================

function watch () {
var opts = {
var options = {
ignoreInitial: false
};

// CSS
gulp.watch(config.task.css.src, opts, gulp.parallel(lintCss, css));
gulp.watch(config.task.css.src, options, gulp.parallel(lintCss, css));

// Image
gulp.watch(config.task.image.src, opts, gulp.parallel(image));
gulp.watch(config.task.image.src, options, gulp.parallel(image));

// JS
gulp.watch(config.task.jsAppPre.src, opts, gulp.parallel(lintJs, jsAppPre));
gulp.watch(config.task.jsAppPost.src, opts, gulp.parallel(lintJs, jsAppPost));
gulp.watch(config.task.jsAppPostDefer.src, opts, gulp.parallel(lintJs, jsAppPostDefer));
gulp.watch(config.task.jsThing.src, opts, gulp.parallel(lintJs, jsThing));
gulp.watch(config.task.jsAppPre.src, options, gulp.parallel(lintJs, jsAppPre));
gulp.watch(config.task.jsAppPost.src, options, gulp.parallel(lintJs, jsAppPost));
gulp.watch(config.task.jsAppPostDefer.src, options, gulp.parallel(lintJs, jsAppPostDefer));
gulp.watch(config.task.jsThing.src, options, gulp.parallel(lintJs, jsThing));
}


Expand Down

0 comments on commit 72f54c6

Please sign in to comment.