Integrated error reporting: closes #2 and closes #4

This commit is contained in:
Philipp Kunz 2015-12-05 22:29:06 +01:00
parent 338e1c8497
commit a3584988f7
6 changed files with 44 additions and 11 deletions

View File

@ -5,7 +5,12 @@ var GulpBrowserBrowserify;
return function () { return function () {
return through.obj(function (file, enc, cb) { return through.obj(function (file, enc, cb) {
var bundleCallback = function (err, bufferedContent) { var bundleCallback = function (err, bufferedContent) {
if (Buffer.isBuffer(bufferedContent)) {
file.contents = bufferedContent; file.contents = bufferedContent;
}
else {
pr.beautylog.error("gulp-browser: .browserify() " + err.message);
}
cb(null, file); cb(null, file);
}; };
browserify(file) browserify(file)

View File

@ -7,7 +7,8 @@
"test": "(cd ts/compile && node compile.js) && (node test.js)", "test": "(cd ts/compile && node compile.js) && (node test.js)",
"reinstall": "(rm -r node_modules && npm install)", "reinstall": "(rm -r node_modules && npm install)",
"release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)", "release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)",
"startdev": "(git checkout master && git pull origin master)" "update": "(git checkout master && git pull origin master && npm install)",
"upgrade": "(npm run update) && (ncu upgradeAll && npm install)"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -31,9 +32,9 @@
"through2": "2.0.0" "through2": "2.0.0"
}, },
"devDependencies": { "devDependencies": {
"beautylog": "1.0.4", "beautylog": "1.0.6",
"gulp": "3.9.0", "gulp": "3.9.0",
"gulp-callfunction": "0.0.10", "gulp-callfunction": "0.0.10",
"gulp-typescript": "2.9.2" "gulp-typescript": "2.10.0"
} }
} }

17
test.js
View File

@ -4,13 +4,24 @@ var gulpBrowser = require("./index.js");
var pr = require("pushrocks"); var pr = require("pushrocks");
var gulpCallFunction = require("gulp-callfunction"); var gulpCallFunction = require("gulp-callfunction");
var pipeWorked = function () { var pipeWorked = function () {
pr.beautylog.success("Pipe didn't break! Ready for Primetime!"); pr.beautylog.info("Pipe didn't break! Ready for Primetime!");
}; };
pr.beautylog.log('Now trying to browserify a testfile...'); pr.beautylog.log('Now trying to browserify a testfile...');
gulp.task('gulpBrowserTest', function (cb) { gulp.task('gulpBrowserTest', function (cb) {
gulp.src('./test/*.js') var stream = gulp.src('./test/browserifyGulpTest.js')
.pipe(gulpBrowser.browserify()) .pipe(gulpBrowser.browserify())
.pipe(gulp.dest("./test/result/")) .pipe(gulp.dest("./test/result/"))
.pipe(gulpCallFunction(pipeWorked)); .pipe(gulpCallFunction(pipeWorked));
return stream;
}); });
gulp.start.apply(gulp, ['gulpBrowserTest']); gulp.task('gulpBrowserTestError', function (cb) {
var stream = gulp.src('./test/browserifyGulpTestError.js')
.pipe(gulpBrowser.browserify())
.pipe(gulp.dest("./test/result/"))
.pipe(gulpCallFunction(pipeWorked));
return stream;
});
gulp.task("default", ['gulpBrowserTest', 'gulpBrowserTestError'], function () {
pr.beautylog.success("Test passed!");
});
gulp.start.apply(gulp, ['default']);

View File

@ -0,0 +1 @@
var myError = require("my-error");

View File

@ -4,7 +4,11 @@ module GulpBrowserBrowserify {
return function() { return function() {
return through.obj((file, enc, cb) => { //this is the trough object that gets returned by gulpBrowser.browserify(); return through.obj((file, enc, cb) => { //this is the trough object that gets returned by gulpBrowser.browserify();
var bundleCallback = function(err, bufferedContent) { var bundleCallback = function(err, bufferedContent) {
if (Buffer.isBuffer(bufferedContent)){
file.contents = bufferedContent; file.contents = bufferedContent;
} else {
pr.beautylog.error("gulp-browser: .browserify() " + err.message);
}
cb(null,file); cb(null,file);
}; };
browserify(file) browserify(file)

View File

@ -5,14 +5,25 @@ var pr = require("pushrocks");
var gulpCallFunction = require("gulp-callfunction"); var gulpCallFunction = require("gulp-callfunction");
var pipeWorked = function() { var pipeWorked = function() {
pr.beautylog.success("Pipe didn't break! Ready for Primetime!"); pr.beautylog.info("Pipe didn't break! Ready for Primetime!");
}; };
pr.beautylog.log('Now trying to browserify a testfile...'); pr.beautylog.log('Now trying to browserify a testfile...');
gulp.task('gulpBrowserTest',function(cb) { gulp.task('gulpBrowserTest',function(cb) {
gulp.src('./test/*.js') var stream =gulp.src('./test/browserifyGulpTest.js')
.pipe(gulpBrowser.browserify()) .pipe(gulpBrowser.browserify())
.pipe(gulp.dest("./test/result/")) .pipe(gulp.dest("./test/result/"))
.pipe(gulpCallFunction(pipeWorked)); .pipe(gulpCallFunction(pipeWorked));
return stream;
}); });
gulp.start.apply(gulp, ['gulpBrowserTest']); gulp.task('gulpBrowserTestError',function(cb) {
var stream = gulp.src('./test/browserifyGulpTestError.js')
.pipe(gulpBrowser.browserify())
.pipe(gulp.dest("./test/result/"))
.pipe(gulpCallFunction(pipeWorked));
return stream;
});
gulp.task("default",['gulpBrowserTest','gulpBrowserTestError'],function(){
pr.beautylog.success("Test passed!");
});
gulp.start.apply(gulp, ['default']);