Skip to content

Commit

Permalink
make gulp working with Browserify
Browse files Browse the repository at this point in the history
  • Loading branch information
erykpiast committed May 13, 2015
1 parent ab8ee6a commit f148d70
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 26 deletions.
2 changes: 1 addition & 1 deletion demo/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import fileManager from '../src/js/file-manager';
import fileManager from '../src/file-manager/js';

fileManager(document.body);
22 changes: 12 additions & 10 deletions gulp/build/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ module.exports = function buildJsTask(before) {
}

return before(changedFiles)
.pipe(bundler.bundle())
.on('error', function(err) {
gutil.log('Browserify error:', err.message);
})
.pipe(source(config.dist.js.bundleName))
.pipe(gulp.dest(config.dist.js.dir))
.on('finish', function() {
gutil.log('building finished!');
})
.pipe(connect.reload());
.then(function() {
return bundler.bundle()
.on('error', function(err) {
gutil.log('Browserify error:', err.message);
})
.pipe(source(config.dist.js.bundleName))
.pipe(gulp.dest(config.dist.js.dir))
.on('finish', function() {
gutil.log('building finished!');
})
.pipe(connect.reload());
});
};


Expand Down
14 changes: 12 additions & 2 deletions gulp/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,29 @@ var gutil = require('gulp-util');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');

var q = require('q');

var config = require('./config');

module.exports = function lintTask(cb, files) {
var deferred = q.defer();

gutil.log('linting is starting...');

return gulp.src(files || config.src.js.files)
gulp.src(files || config.src.js.files)
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(jshint.reporter('fail'))
.on('error', function(err) {
gutil.log('linter error:', err.message);

deferred.reject(err);
})
.on('finish', function() {
.on('finish', function(e) {
gutil.log('linting finished!');

deferred.resolve(e);
});

return deferred.promise;
};
28 changes: 15 additions & 13 deletions gulp/test/build-watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,21 @@ module.exports = function buildTestsTask(before, after) {
building = true;

return before(changedFiles)
.pipe(bundler.bundle())
.pipe(source(config.test.bundle.name))
.pipe(gulp.dest(config.test.bundle.dir))
.pipe(after(changedFiles))
.on('error', function(err) {
building = false;

gutil.log('Building error', err.message);
})
.on('end', function() {
building = false;

gutil.log('Building finished!');
.then(function() {
return bundler.bundle()
.pipe(source(config.test.bundle.name))
.pipe(gulp.dest(config.test.bundle.dir))
.pipe(after(changedFiles))
.on('error', function(err) {
building = false;

gutil.log('Building error', err.message);
})
.on('end', function() {
building = false;

gutil.log('Building finished!');
});
});
} else {
return null;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"karma-phantomjs-launcher": "~0.1",
"mocha": "~2.2",
"proxyquireify": "~2.0",
"q": "~1.4",
"run-sequence": "~1.0",
"vinyl-source-stream": "~1.1",
"watchify": "~3.2"
Expand Down

0 comments on commit f148d70

Please sign in to comment.