Compare commits
30 Commits
Author | SHA1 | Date | |
---|---|---|---|
61dc3347c7 | |||
2de34d9928 | |||
2c69bdd39c | |||
130f8b00d7 | |||
a87263888c | |||
802a348123 | |||
74bbd71ef4 | |||
86f7e0631b | |||
0657edac50 | |||
01a89ecad1 | |||
213cd764d8 | |||
244048fccb | |||
aee39d4a33 | |||
f5f1d59c79 | |||
895063ec65 | |||
ba29214eea | |||
5fe7d563d0 | |||
29534a3c6d | |||
e5cbefd195 | |||
83ddb95968 | |||
7afda4e508 | |||
f459bd5537 | |||
53dba94a78 | |||
47b5d718ee | |||
e0902b9f6c | |||
5ee39fc04d | |||
40254e394e | |||
9306dcf0a1 | |||
9b6609a2e5 | |||
943fcf8634 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -8,3 +8,7 @@ ts/*.js.map
|
|||||||
ts/typings/
|
ts/typings/
|
||||||
|
|
||||||
test/result/
|
test/result/
|
||||||
|
|
||||||
|
coverage/
|
||||||
|
|
||||||
|
docs/
|
@ -1,3 +1,4 @@
|
|||||||
node_modules
|
node_modules
|
||||||
test
|
test
|
||||||
ts
|
ts
|
||||||
|
coverage/
|
@ -1,8 +1,7 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- '4.1'
|
- 4
|
||||||
before_install:
|
- stable
|
||||||
- npm install -g tsd
|
|
||||||
deploy:
|
deploy:
|
||||||
provider: npm
|
provider: npm
|
||||||
email: npm@lossless.digital
|
email: npm@lossless.digital
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
# gulp-browser
|
# gulp-browser
|
||||||
browserify and other goodies for gulp
|
browserify and other goodies for gulp
|
||||||
|
|
||||||
### Build Status/Dependencies
|
### Status
|
||||||
[](https://travis-ci.org/pushrocks/gulp-browser)
|
[](https://travis-ci.org/pushrocks/gulp-browser)
|
||||||
[](https://david-dm.org/pushrocks/gulp-browser)
|
[](https://david-dm.org/pushrocks/gulp-browser)
|
||||||
[](https://www.bithound.io/github/pushrocks/gulp-browser/master/dependencies/npm)
|
[](https://www.bithound.io/github/pushrocks/gulp-browser/master/dependencies/npm)
|
||||||
[](https://www.bithound.io/github/pushrocks/gulp-browser)
|
[](https://www.bithound.io/github/pushrocks/gulp-browser)
|
||||||
|
[](https://codecov.io/github/pushrocks/gulp-browser?branch=master)
|
||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
gulp-browser is meant to be easy:
|
gulp-browser is meant to be easy:
|
||||||
@ -31,6 +31,6 @@ gulp-browser is meant to be easy:
|
|||||||
[](https://www.bithound.io/github/pushrocks/gulp-browser/master/dependencies/npm)
|
[](https://www.bithound.io/github/pushrocks/gulp-browser/master/dependencies/npm)
|
||||||
|
|
||||||
### About the authors:
|
### About the authors:
|
||||||
[](https://lossless.com/)
|
[](https://lossless.com/)
|
||||||
|
|
||||||
[](https://paypal.me/lossless)
|
[](https://paypal.me/lossless)
|
34
dist/gulpbrowser.browserify.js
vendored
Normal file
34
dist/gulpbrowser.browserify.js
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
var plugins = require("./gulpbrowser.plugins");
|
||||||
|
var browserify = function () {
|
||||||
|
var forEach = function (file, enc, cb) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
};
|
||||||
|
module.exports = browserify;
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImd1bHBicm93c2VyLmJyb3dzZXJpZnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUM1QyxJQUFPLE9BQU8sV0FBVyx1QkFBdUIsQ0FBQyxDQUFDO0FBR2xELElBQUksVUFBVSxHQUFJO0lBRWQsSUFBSSxPQUFPLEdBQUcsVUFBUyxJQUFJLEVBQUUsR0FBRyxFQUFFLEVBQUU7UUFFaEMsSUFBSSxjQUFjLEdBQUcsVUFBUyxHQUFHLEVBQUUsZUFBZTtZQUM5QyxFQUFFLENBQUMsQ0FBQyxNQUFNLENBQUMsUUFBUSxDQUFDLGVBQWUsQ0FBQyxDQUFDLENBQUEsQ0FBQztnQkFDbEMsSUFBSSxDQUFDLFFBQVEsR0FBRyxlQUFlLENBQUM7WUFDcEMsQ0FBQztZQUFDLElBQUksQ0FBQyxDQUFDO2dCQUNKLE9BQU8sQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLDhCQUE4QixHQUFHLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQztnQkFDdEUsRUFBRSxDQUFDLElBQUksS0FBSyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsRUFBQyxJQUFJLENBQUMsQ0FBQztnQkFDaEMsTUFBTSxDQUFDO1lBQ1gsQ0FBQztZQUNELEVBQUUsQ0FBQyxJQUFJLEVBQUMsSUFBSSxDQUFDLENBQUM7UUFDbEIsQ0FBQyxDQUFDO1FBRUYsRUFBRSxDQUFBLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNL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gICAgXG4gICAgICAgIGxldCBidW5kbGVDYWxsYmFjayA9IGZ1bmN0aW9uKGVyciwgYnVmZmVyZWRDb250ZW50KSB7IC8vIG91ciBidW5kbGUgY2FsbGJhY2sgZm9yIHdoZW4gYnJvd3NlcmlmeSBpcyBmaW5pc2hlZFxuICAgICAgICAgICAgaWYgKEJ1ZmZlci5pc0J1ZmZlcihidWZmZXJlZENvbnRlbnQpKXtcbiAgICAgICAgICAgICAgICBmaWxlLmNvbnRlbnRzID0gYnVmZmVyZWRDb250ZW50O1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBwbHVnaW5zLmJlYXV0eWxvZy5lcnJvcihcImd1bHAtYnJvd3NlcjogLmJyb3dzZXJpZnkoKSBcIiArIGVyci5tZXNzYWdlKTtcbiAgICAgICAgICAgICAgICBjYihuZXcgRXJyb3IoZXJyLm1lc3NhZ2UpLGZpbGUpO1xuICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNiKG51bGwsZmlsZSk7XG4gICAgICAgIH07XG4gICAgICAgIFxuICAgICAgICBpZihmaWxlLmNvbnRlbnRzLmxlbmd0aCA+IDApe1xuICAgICAgICAgICAgcGx1Z2lucy5icm93c2VyaWZ5KGZpbGUsIHsgYmFzZWRpcjogZmlsZS5iYXNlIH0pXG4gICAgICAgICAgICAgICAgLmJ1bmRsZShidW5kbGVDYWxsYmFjayk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwbHVnaW5zLmJlYXV0eWxvZy53YXJuKFwiZ3VscC1icm93c2VyOiAuYnJvd3NlcmlmeSgpIGZpbGUuY29udGVudHMgYXBwZWFycyB0byBiZSBlbXB0eVwiKTtcbiAgICAgICAgICAgIGNiKG51bGwsZmlsZSk7XG4gICAgICAgIH07XG4gICAgfVxuICAgICAgICBcbiAgICBsZXQgYXRFbmQgPSBmdW5jdGlvbihjYil7XG4gICAgICAgIGNiKCk7XG4gICAgfSAvLyBubyBuZWVkIHRvIGNsZWFuIHVwIGFmdGVyIG91cnNlbHZlc1xuICAgIFxuICAgIHJldHVybiBwbHVnaW5zLnRocm91Z2gub2JqKGZvckVhY2gsYXRFbmQpOyAvLyB0aGlzIGlzIHRoZSB0aHJvdWdoIG9iamVjdCB0aGF0IGdldHMgcmV0dXJuZWQgYnkgZ3VscEJyb3dzZXIuYnJvd3NlcmlmeSgpO1xuIH07XG5cbmV4cG9ydCA9IGJyb3dzZXJpZnk7Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
|
8
dist/gulpbrowser.plugins.js
vendored
Normal file
8
dist/gulpbrowser.plugins.js
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
"use strict";
|
||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
exports.beautylog = require("beautylog");
|
||||||
|
exports.through = require("through2");
|
||||||
|
exports.path = require("path");
|
||||||
|
exports.browserify = require("browserify");
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImd1bHBicm93c2VyLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUNqQyxpQkFBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztBQUNqQyxlQUFPLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0FBQzlCLFlBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDdkIsa0JBQVUsR0FBRyxPQUFPLENBQUMsWUFBWSxDQUFDLENBQUMiLCJmaWxlIjoiZ3VscGJyb3dzZXIucGx1Z2lucy5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmV4cG9ydCBsZXQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTtcbmV4cG9ydCBsZXQgdGhyb3VnaCA9IHJlcXVpcmUoXCJ0aHJvdWdoMlwiKTtcbmV4cG9ydCBsZXQgcGF0aCA9IHJlcXVpcmUoXCJwYXRoXCIpO1xuZXhwb3J0IGxldCBicm93c2VyaWZ5ID0gcmVxdWlyZShcImJyb3dzZXJpZnlcIik7XG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
5
dist/index.js
vendored
Normal file
5
dist/index.js
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
"use strict";
|
||||||
|
exports.browserify = require("./gulpbrowser.browserify");
|
||||||
|
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0Qzs7QUFFOUIsa0JBQVUsV0FBVywwQkFBMEIsQ0FBQyxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4vdHlwaW5ncy9tYWluLmQudHNcIiAvPlxuXG5leHBvcnQgaW1wb3J0IGJyb3dzZXJpZnkgPSByZXF1aXJlKFwiLi9ndWxwYnJvd3Nlci5icm93c2VyaWZ5XCIpO1xuXG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
12
index.d.ts
vendored
12
index.d.ts
vendored
@ -1,12 +0,0 @@
|
|||||||
/// <reference path="ts/typings/main.d.ts" />
|
|
||||||
declare module GulpBrowserBrowserify {
|
|
||||||
function init(): () => any;
|
|
||||||
}
|
|
||||||
declare var plugins: {
|
|
||||||
beautylog: any;
|
|
||||||
through: any;
|
|
||||||
gutil: any;
|
|
||||||
path: any;
|
|
||||||
browserify: any;
|
|
||||||
};
|
|
||||||
declare var gulpBrowser: any;
|
|
37
index.js
37
index.js
@ -1,37 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
/// <reference path="./index.ts" />
|
|
||||||
var GulpBrowserBrowserify;
|
|
||||||
(function (GulpBrowserBrowserify) {
|
|
||||||
function init() {
|
|
||||||
return function () {
|
|
||||||
return plugins.through.obj(function (file, enc, cb) {
|
|
||||||
var bundleCallback = function (err, bufferedContent) {
|
|
||||||
if (Buffer.isBuffer(bufferedContent)) {
|
|
||||||
file.contents = bufferedContent;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
plugins.beautylog.error("gulp-browser: .browserify() " + err.message);
|
|
||||||
}
|
|
||||||
cb(null, file);
|
|
||||||
};
|
|
||||||
plugins.browserify(file, { basedir: file.base })
|
|
||||||
.bundle(bundleCallback);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
GulpBrowserBrowserify.init = init;
|
|
||||||
})(GulpBrowserBrowserify || (GulpBrowserBrowserify = {}));
|
|
||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
/// <reference path="./modulebrowserify.ts" />
|
|
||||||
var plugins = {
|
|
||||||
beautylog: require("beautylog"),
|
|
||||||
through: require("through2"),
|
|
||||||
gutil: require("gulp-util"),
|
|
||||||
path: require("path"),
|
|
||||||
browserify: require("browserify")
|
|
||||||
};
|
|
||||||
//create the return object
|
|
||||||
var gulpBrowser = {};
|
|
||||||
gulpBrowser.browserify = GulpBrowserBrowserify.init();
|
|
||||||
module.exports = gulpBrowser;
|
|
4
npmts.json
Normal file
4
npmts.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"mode":"default",
|
||||||
|
"coveralls":true
|
||||||
|
}
|
16
package.json
16
package.json
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "gulp-browser",
|
"name": "gulp-browser",
|
||||||
"version": "1.0.5",
|
"version": "1.2.2",
|
||||||
"description": "browserify and other goodies for gulp",
|
"description": "browserify and other goodies for gulp",
|
||||||
"main": "index.js",
|
"main": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)",
|
"test": "(npmts)",
|
||||||
"reinstall": "(rm -r node_modules && npm install)",
|
"reinstall": "(rm -r node_modules && npm install)",
|
||||||
@ -25,14 +25,14 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/gulp-browser",
|
"homepage": "https://github.com/pushrocks/gulp-browser",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "2.0.4",
|
"beautylog": "3.1.2",
|
||||||
"browserify": "13.0.0",
|
"browserify": "13.0.0",
|
||||||
"gulp-util": "3.0.7",
|
"through2": "2.0.1"
|
||||||
"through2": "2.0.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "3.9.0",
|
"gulp": "3.9.1",
|
||||||
"gulp-callfunction": "0.0.10",
|
"gulp-function": "1.2.0",
|
||||||
"npmts": "^2.0.2"
|
"npmts": "^4.0.1",
|
||||||
|
"should": "^8.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
42
test/test.js
42
test/test.js
@ -1,29 +1,41 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
var plugins = {
|
var plugins = {
|
||||||
beautylog: require("beautylog"),
|
beautylog: require("beautylog"),
|
||||||
gulp: require("gulp"),
|
gulp: require("gulp"),
|
||||||
gulpBrowser: require("../index.js"),
|
gulpBrowser: require("../dist/index.js"),
|
||||||
gulpCallFunction: require("gulp-callfunction")
|
gulpFunction: require("gulp-function")
|
||||||
};
|
};
|
||||||
|
var should = require("should");
|
||||||
describe("gulpBrowser", function () {
|
describe("gulpBrowser", function () {
|
||||||
describe(".browserify", function () {
|
describe(".browserify", function () {
|
||||||
it("should run through smoothly", function (done) {
|
it("should run through smoothly", function (done) {
|
||||||
this.timeout(15000);
|
this.timeout(30000);
|
||||||
plugins.gulp.task('gulpBrowserNormal', function (cb) {
|
var stream = plugins.gulp.src('./test/testBrowserifyNormal.js')
|
||||||
var stream = plugins.gulp.src('./test/browserifyGulpTest.js')
|
|
||||||
.pipe(plugins.gulpBrowser.browserify())
|
.pipe(plugins.gulpBrowser.browserify())
|
||||||
.pipe(plugins.gulp.dest("./test/result/"))
|
.pipe(plugins.gulp.dest("./test/result/"))
|
||||||
.pipe(plugins.gulpCallFunction(done));
|
.pipe(plugins.gulpFunction(done));
|
||||||
return stream;
|
|
||||||
});
|
});
|
||||||
plugins.gulp.start.apply(plugins.gulp, ['gulpBrowserNormal']);
|
it("should throw an error, when a module is not found", function (done) {
|
||||||
|
var d = require('domain').create();
|
||||||
|
var doneCalled = false;
|
||||||
|
d.on("error", function (error) {
|
||||||
|
console.log(error.message);
|
||||||
|
if (!doneCalled) {
|
||||||
|
done();
|
||||||
|
doneCalled = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
d.run(function () {
|
||||||
|
var stream = plugins.gulp.src("./test/testBrowserifyError.js")
|
||||||
|
.pipe(plugins.gulpBrowser.browserify());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
it("should run through with an empty file", function (done) {
|
||||||
plugins.gulp.task('gulpBrowserTestError', function (cb) {
|
var stream = plugins.gulp.src('./test/testBrowserifyEmpty.js')
|
||||||
plugins.beautylog.info("Expecting an error:");
|
|
||||||
var stream = plugins.gulp.src('./test/browserifyGulpTestError.js')
|
|
||||||
.pipe(plugins.gulpBrowser.browserify())
|
.pipe(plugins.gulpBrowser.browserify())
|
||||||
.pipe(plugins.gulp.dest("./test/result/"));
|
.pipe(plugins.gulp.dest("./test/result/"))
|
||||||
return stream;
|
.pipe(plugins.gulpFunction(done));
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//# sourceMappingURL=test.js.map
|
1
test/test.js.map
Normal file
1
test/test.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"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,CAAC,GAAG,CAAC,+BAA+B,CAAC;qBACzD,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC,CAAC;YAChD,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,uCAAuC,EAAE,UAAU,IAAI;YACtD,IAAI,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,+BAA+B,CAAC;iBACzD,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;iBACtC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;iBACzC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
44
test/test.ts
Normal file
44
test/test.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/// <reference path="../ts/typings/main.d.ts" />
|
||||||
|
let plugins = {
|
||||||
|
beautylog: require("beautylog"),
|
||||||
|
gulp: require("gulp"),
|
||||||
|
gulpBrowser: require("../dist/index.js"),
|
||||||
|
gulpFunction: require("gulp-function")
|
||||||
|
};
|
||||||
|
let should = require("should");
|
||||||
|
|
||||||
|
|
||||||
|
describe("gulpBrowser", function () {
|
||||||
|
describe(".browserify", function () {
|
||||||
|
it("should run through smoothly", function (done) {
|
||||||
|
this.timeout(30000);
|
||||||
|
let stream = plugins.gulp.src('./test/testBrowserifyNormal.js')
|
||||||
|
.pipe(plugins.gulpBrowser.browserify())
|
||||||
|
.pipe(plugins.gulp.dest("./test/result/"))
|
||||||
|
.pipe(plugins.gulpFunction(done));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should throw an error, when a module is not found", function (done) {
|
||||||
|
let d = require('domain').create();
|
||||||
|
let doneCalled = false
|
||||||
|
d.on("error",function(error){
|
||||||
|
console.log(error.message)
|
||||||
|
if(!doneCalled){
|
||||||
|
done();
|
||||||
|
doneCalled = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
d.run(function() {
|
||||||
|
let stream = plugins.gulp.src("./test/testBrowserifyError.js")
|
||||||
|
.pipe(plugins.gulpBrowser.browserify());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should run through with an empty file", function (done) {
|
||||||
|
let stream = plugins.gulp.src('./test/testBrowserifyEmpty.js')
|
||||||
|
.pipe(plugins.gulpBrowser.browserify())
|
||||||
|
.pipe(plugins.gulp.dest("./test/result/"))
|
||||||
|
.pipe(plugins.gulpFunction(done));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
0
test/testBrowserifyEmpty.js
Normal file
0
test/testBrowserifyEmpty.js
Normal file
36
ts/gulpbrowser.browserify.ts
Normal file
36
ts/gulpbrowser.browserify.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
import plugins = require("./gulpbrowser.plugins");
|
||||||
|
|
||||||
|
|
||||||
|
let browserify = function() {
|
||||||
|
|
||||||
|
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;
|
||||||
|
} else {
|
||||||
|
plugins.beautylog.error("gulp-browser: .browserify() " + err.message);
|
||||||
|
cb(new Error(err.message),file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let 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();
|
||||||
|
};
|
||||||
|
|
||||||
|
export = browserify;
|
5
ts/gulpbrowser.plugins.ts
Normal file
5
ts/gulpbrowser.plugins.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
/// <reference path="./typings/main.d.ts" />
|
||||||
|
export let beautylog = require("beautylog");
|
||||||
|
export let through = require("through2");
|
||||||
|
export let path = require("path");
|
||||||
|
export let browserify = require("browserify");
|
16
ts/index.ts
16
ts/index.ts
@ -1,18 +1,4 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
/// <reference path="./modulebrowserify.ts" />
|
|
||||||
|
|
||||||
var plugins = {
|
export import browserify = require("./gulpbrowser.browserify");
|
||||||
beautylog: require("beautylog"),
|
|
||||||
through: require("through2"),
|
|
||||||
gutil: require("gulp-util"),
|
|
||||||
path: require("path"),
|
|
||||||
browserify: require("browserify")
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//create the return object
|
|
||||||
var gulpBrowser:any = {};
|
|
||||||
|
|
||||||
gulpBrowser.browserify = GulpBrowserBrowserify.init();
|
|
||||||
|
|
||||||
module.exports = gulpBrowser;
|
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
/// <reference path="./index.ts" />
|
|
||||||
module GulpBrowserBrowserify {
|
|
||||||
export function init() {
|
|
||||||
return function() {
|
|
||||||
return plugins.through.obj((file, enc, cb) => { //this is the through object that gets returned by gulpBrowser.browserify();
|
|
||||||
var bundleCallback = function(err, bufferedContent) {
|
|
||||||
if (Buffer.isBuffer(bufferedContent)){
|
|
||||||
file.contents = bufferedContent;
|
|
||||||
} else {
|
|
||||||
plugins.beautylog.error("gulp-browser: .browserify() " + err.message);
|
|
||||||
}
|
|
||||||
cb(null,file);
|
|
||||||
};
|
|
||||||
plugins.browserify(file, { basedir: file.base })
|
|
||||||
.bundle(bundleCallback)
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
31
ts/test.ts
31
ts/test.ts
@ -1,31 +0,0 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
|
||||||
var plugins = {
|
|
||||||
beautylog: require("beautylog"),
|
|
||||||
gulp: require("gulp"),
|
|
||||||
gulpBrowser: require("../index.js"),
|
|
||||||
gulpCallFunction: require("gulp-callfunction")
|
|
||||||
};
|
|
||||||
|
|
||||||
describe("gulpBrowser",function(){
|
|
||||||
describe(".browserify",function(){
|
|
||||||
it("should run through smoothly",function(done){
|
|
||||||
this.timeout(15000);
|
|
||||||
plugins.gulp.task('gulpBrowserNormal',function(cb) {
|
|
||||||
var stream = plugins.gulp.src('./test/browserifyGulpTest.js')
|
|
||||||
.pipe(plugins.gulpBrowser.browserify())
|
|
||||||
.pipe(plugins.gulp.dest("./test/result/"))
|
|
||||||
.pipe(plugins.gulpCallFunction(done));
|
|
||||||
return stream;
|
|
||||||
});
|
|
||||||
plugins.gulp.start.apply(plugins.gulp, ['gulpBrowserNormal']);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
plugins.gulp.task('gulpBrowserTestError',function(cb) {
|
|
||||||
plugins.beautylog.info("Expecting an error:");
|
|
||||||
var stream = plugins.gulp.src('./test/browserifyGulpTestError.js')
|
|
||||||
.pipe(plugins.gulpBrowser.browserify())
|
|
||||||
.pipe(plugins.gulp.dest("./test/result/"))
|
|
||||||
return stream;
|
|
||||||
});
|
|
15
ts/tsd.json
15
ts/tsd.json
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "v4",
|
|
||||||
"repo": "borisyankov/DefinitelyTyped",
|
|
||||||
"ref": "master",
|
|
||||||
"path": "typings",
|
|
||||||
"bundle": "typings/tsd.d.ts",
|
|
||||||
"installed": {
|
|
||||||
"node/node.d.ts": {
|
|
||||||
"commit": "3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9"
|
|
||||||
},
|
|
||||||
"browserify/browserify.d.ts": {
|
|
||||||
"commit": "3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"ambientDependencies": {
|
"ambientDependencies": {
|
||||||
"browserify": "github:DefinitelyTyped/DefinitelyTyped/browserify/browserify.d.ts#3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9",
|
"browserify": "github:DefinitelyTyped/DefinitelyTyped/browserify/browserify.d.ts",
|
||||||
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
||||||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9"
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user