]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Add prettier error handling to gulp-babel
authorGeoff Kimball <geoff@zurb.com>
Mon, 8 Feb 2016 22:15:53 +0000 (14:15 -0800)
committerGeoff Kimball <geoff@zurb.com>
Mon, 8 Feb 2016 22:15:53 +0000 (14:15 -0800)
gulp/javascript.js
package.json

index caa15b383fb9d1549a087300fb6c3eaa7b40d72d..246e53888b218338612ab9bba78d0aaaa075beac 100644 (file)
@@ -1,4 +1,5 @@
 var gulp = require('gulp');
+var chalk = require('chalk');
 var concat = require('gulp-concat');
 var babel = require('gulp-babel');
 
@@ -27,9 +28,7 @@ gulp.task('javascript', ['javascript:foundation', 'javascript:deps', 'javascript
 gulp.task('javascript:foundation', function() {
   return gulp.src(FOUNDATION)
     .pipe(babel()
-      .on('error', function(err) {
-        console.log(err);
-      }))
+      .on('error', onBabelError))
     .pipe(concat('foundation.js'))
     .pipe(gulp.dest('_build/assets/js'));
 });
@@ -45,3 +44,18 @@ gulp.task('javascript:docs', function() {
     .pipe(concat('docs.js'))
     .pipe(gulp.dest('_build/assets/js'));
 });
+
+function onBabelError(err) {
+  console.log(
+    chalk.red(
+      err.fileName +
+      (
+          err.loc ?
+          '(' + err.loc.line + ',' + err.loc.column + '): ' :
+          ': '
+      )
+    ) +
+    'error Babel: ' + err.message + '\n' +
+    err.codeFrame
+  );
+}
index 5700a8f4d08a646f8c410bb9f05b41c3cc8938ad..28239e24040e4aa30569f9ccaf7fc81ab45e35f8 100644 (file)
@@ -29,6 +29,7 @@
     "babel-plugin-transform-es2015-template-literals": "^6.3.13",
     "bootcamp": "^1.1.7",
     "browser-sync": "^2.8.2",
+    "chalk": "^1.1.1",
     "clipboard": "^1.5.5",
     "corejs-typeahead": "corejavascript/typeahead.js",
     "foundation-docs": "zurb/foundation-docs",