gulp-browser/dist/gulpbrowser.browserify.js

35 lines
4.5 KiB
JavaScript
Raw Normal View History

"use strict";
2016-02-26 16:57:53 +00:00
/// <reference path="./typings/main.d.ts" />
var plugins = require("./gulpbrowser.plugins");
var browserify = function () {
var forEach = function (file, enc, cb) {
2016-02-26 16:57:53 +00:00
var bundleCallback = function (err, bufferedContent) {
if (Buffer.isBuffer(bufferedContent)) {
file.contents = bufferedContent;
}
else {
plugins.beautylog.error("gulp-browser: .browserify() " + err.message);
cb(new Error(err.message), file);
return;
2016-02-26 16:57:53 +00:00
}
cb(null, file);
};
if (file.contents.length > 0) {
plugins.browserify(file, { basedir: file.base })
.bundle(bundleCallback);
}
else {
plugins.beautylog.warn("gulp-browser: .browserify() file.contents appears to be empty");
cb(null, file);
}
;
};
var atEnd = function (cb) {
cb();
}; // no need to clean up after ourselves
return plugins.through.obj(forEach, atEnd); // this is the through object that gets returned by gulpBrowser.browserify();
2016-02-26 16:57:53 +00:00
};
module.exports = browserify;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImd1bHBicm93c2VyLmJyb3dzZXJpZnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUM1QyxJQUFPLE9BQU8sV0FBVyx1QkFBdUIsQ0FBQyxDQUFDO0FBR2xELElBQUksVUFBVSxHQUFJO0lBRWQsSUFBSSxPQUFPLEdBQUcsVUFBUyxJQUFJLEVBQUUsR0FBRyxFQUFFLEVBQUU7UUFFaEMsSUFBSSxjQUFjLEdBQUcsVUFBUyxHQUFHLEVBQUUsZUFBZTtZQUM5QyxFQUFFLENBQUMsQ0FBQyxNQUFNLENBQUMsUUFBUSxDQUFDLGVBQWUsQ0FBQyxDQUFDLENBQUEsQ0FBQztnQkFDbEMsSUFBSSxDQUFDLFFBQVEsR0FBRyxlQUFlLENBQUM7WUFDcEMsQ0FBQztZQUFDLElBQUksQ0FBQyxDQUFDO2dCQUNKLE9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