diff --git a/lib/stream-bundles-watch.js b/lib/stream-bundles-watch.js index 2f51cfde..86e7a7d5 100644 --- a/lib/stream-bundles-watch.js +++ b/lib/stream-bundles-watch.js @@ -73,7 +73,7 @@ function _bundle(config, env) { .pipe(gif(resultOpts, results(resultOpts))) .pipe(gulp.dest(config.options.dest)) .pipe(through.obj(function (file, enc, cb) { - bundleDone(prettyScriptsBundleName, start); + bundleDone(prettyScriptsBundleName, start, config.options.callback, file); })); }); @@ -109,7 +109,7 @@ function _bundle(config, env) { .pipe(gif(resultOpts, results(resultOpts))) .pipe(gulp.dest(config.options.dest)) .pipe(through.obj(function (file, enc, cb) { - bundleDone(prettyStylesBundleName, start); + bundleDone(prettyStylesBundleName, start, config.options.callback, file); })); }); diff --git a/lib/watch/bundle-done.js b/lib/watch/bundle-done.js index 5360f8e5..ea74609a 100644 --- a/lib/watch/bundle-done.js +++ b/lib/watch/bundle-done.js @@ -4,10 +4,14 @@ var gulp = require('gulp'), prettyTime = require('pretty-hrtime'), using = require('./../using'); -module.exports = function (name, start) { +module.exports = function (name, start, callback, file) { var hrDuration = process.hrtime(start); // [seconds,nanoseconds] var time = prettyTime(hrDuration); logger.log('Finished bundling', '\'' + gutil.colors.green(name) + '\'', 'after', gutil.colors.magenta(time) ); -}; \ No newline at end of file + + if (callback && typeof callback === 'function') { + callback(file); + } +}; diff --git a/package.json b/package.json index 249739ad..5c4fcc68 100644 --- a/package.json +++ b/package.json @@ -106,12 +106,14 @@ "gulp-jshint": "1.11.0", "gulp-mocha": "2.1.1", "gulp-nice-package": "1.0.0", - "gulp-sass": "2.0.4", + "gulp-sass": "2.0.2", "gulp-shrinkwrap": "2.0.1", "jshint-stylish": "2.0.0", "mocha-lcov-reporter": "0.0.2", "multiline": "1.0.2", + "node-sass": "^4.7.2", "proxyquire": "1.5.0", + "request": "^2.81.0", "rimraf": "^2.5.2", "should": "6.0.3", "sinon": "1.15.3", diff --git a/test/unit/watch/bundle-done-test.js b/test/unit/watch/bundle-done-test.js index 2e630dd3..a8b1e76a 100644 --- a/test/unit/watch/bundle-done-test.js +++ b/test/unit/watch/bundle-done-test.js @@ -9,17 +9,21 @@ describe('bundle-done', function () { var prettyTimeStub = sinon.stub().returns(''); + var callback = sinon.spy(); + var mockFile = {}; var loggerStub = sinon.stub(); loggerStub.log = sinon.spy(); var bundleDone = proxyquire(libPath + '/watch/bundle-done', { 'pretty-hrtime': prettyTimeStub, '../service/logger': loggerStub }); - bundleDone('main.scripts', [ 1800216, 25 ]); + bundleDone('main.scripts', [ 1800216, 25 ], callback, mockFile); prettyTimeStub.calledOnce.should.be.ok; loggerStub.log.calledOnce.should.be.ok; loggerStub.log.calledWith('Finished bundling').should.be.ok; - + + callback.calledOnce.should.be.ok; + callback.calledWith(mockFile).should.be.ok; }); });