added typings, removed beautylog
This commit is contained in:
@ -1,48 +1,49 @@
|
||||
import plugins = require("./gulpbrowser.plugins");
|
||||
import * as stream from 'stream'
|
||||
import plugins = require('./gulpbrowser.plugins')
|
||||
import * as q from 'q'
|
||||
|
||||
|
||||
let browserify = function(transforms = []) {
|
||||
let browserify = function (transforms = []) {
|
||||
|
||||
if (!Array.isArray(transforms)) {
|
||||
transforms = [transforms];
|
||||
transforms = [transforms]
|
||||
}
|
||||
|
||||
let forEach = function(file, enc, cb){ // do this with every chunk (file in gulp terms)
|
||||
let forEach = function (file, enc, cb) { // do this with every chunk (file in gulp terms)
|
||||
|
||||
let bundleCallback = function(err, bufferedContent) { // our bundle callback for when browserify is finished
|
||||
if (Buffer.isBuffer(bufferedContent)){
|
||||
file.contents = bufferedContent;
|
||||
let bundleCallback = function (err, bufferedContent) { // our bundle callback for when browserify is finished
|
||||
if (Buffer.isBuffer(bufferedContent)) {
|
||||
file.contents = bufferedContent
|
||||
} else {
|
||||
plugins.beautylog.error("gulp-browser: .browserify() " + err.message);
|
||||
cb(new Error(err.message),file);
|
||||
return;
|
||||
console.log('gulp-browser: .browserify() ' + err.message)
|
||||
cb(new Error(err.message), file)
|
||||
return
|
||||
}
|
||||
cb(null,file);
|
||||
};
|
||||
cb(null, file)
|
||||
}
|
||||
|
||||
if(file.contents.length > 0){
|
||||
let browserified = plugins.browserify(file, { basedir: file.base });
|
||||
if (file.contents.length > 0) {
|
||||
let browserified = plugins.browserify(file, { basedir: file.base })
|
||||
|
||||
transforms.forEach(function (transform) {
|
||||
if (typeof transform === 'function') {
|
||||
browserified.transform(transform);
|
||||
browserified.transform(transform)
|
||||
} else {
|
||||
browserified.transform(transform.transform, transform.options);
|
||||
browserified.transform(transform.transform, transform.options)
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
browserified.bundle(bundleCallback);
|
||||
browserified.bundle(bundleCallback)
|
||||
} else {
|
||||
plugins.beautylog.warn("gulp-browser: .browserify() file.contents appears to be empty");
|
||||
cb(null,file);
|
||||
console.warn('gulp-browser: .browserify() file.contents appears to be empty')
|
||||
cb(null, file)
|
||||
};
|
||||
}
|
||||
|
||||
let atEnd = function(cb){
|
||||
cb();
|
||||
let atEnd = function (cb) {
|
||||
cb()
|
||||
} // no need to clean up after ourselves
|
||||
|
||||
return plugins.through2.obj(forEach,atEnd); // this is the through object that gets returned by gulpBrowser.browserify();
|
||||
};
|
||||
return plugins.through2.obj(forEach, atEnd) // this is the through object that gets returned by gulpBrowser.browserify();
|
||||
}
|
||||
|
||||
export = browserify;
|
||||
export = browserify
|
||||
|
@ -1,5 +1,4 @@
|
||||
import "typings-global";
|
||||
export import beautylog = require("beautylog");
|
||||
export import through2 = require("through2");
|
||||
export import path = require("path");
|
||||
export import browserify = require("browserify");
|
||||
import 'typings-global'
|
||||
export import through2 = require('through2')
|
||||
export import path = require('path')
|
||||
export import browserify = require('browserify')
|
||||
|
Reference in New Issue
Block a user