Compare commits

..

No commits in common. "master" and "v3.0.3" have entirely different histories.

23 changed files with 310 additions and 6705 deletions

1
.gitignore vendored
View File

@ -2,5 +2,6 @@ node_modules/
npm-debug.log npm-debug.log
test/result/ test/result/
coverage/ coverage/
docs/
pages/ pages/
public public

View File

@ -1,150 +1,37 @@
# gitzone standard image: hosttoday/ht-docker-node:npmts
image: hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: "$CI_BUILD_STAGE"
stages: stages:
- security
- test - test
- release - release
- metadata - page
# ==================== testLEGACY:
# security stage stage: test
# ====================
mirror:
stage: security
script: script:
- npmci git mirror - npmci test legacy
tags: tags:
- docker - docker
- notpriv
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- docker
- notpriv
sast:
stage: security
image: registry.gitlab.com/hosttoday/ht-docker-dbase:npmci
variables:
DOCKER_DRIVER: overlay2
allow_failure: true
services:
- docker:stable-dind
script:
- npmci npm prepare
- npmci npm install
- npmci command npm run build
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
--volume "$PWD:/code"
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
artifacts:
reports:
sast: gl-sast-report.json
tags:
- docker
- priv
# ====================
# test stage
# ====================
testLTS: testLTS:
stage: test stage: test
script: script:
- npmci npm prepare - npmci test lts
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
testSTABLE: testSTABLE:
stage: test stage: test
script: script:
- npmci npm prepare - npmci test stable
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
release: release:
stage: release stage: release
script: script:
- npmci node install stable - npmci publish npm
- npmci npm publish
only:
- tags
tags:
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
image: docker:stable
allow_failure: true
services:
- docker:stable-dind
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
tags:
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger - npmci trigger
only: only:
- tags - tags
tags: tags:
- docker - docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci command npm install -g typedoc typescript
- npmci npm prepare
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
tags:
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true

View File

@ -1,6 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2015 Lossless GmbH Copyright (c) 2015 Push.Rocks
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,57 +1,51 @@
# @pushrocks/gulp-browser # gulp-browser
browserify and other goodies for gulp browserify and other goodies for gulp
## Availabililty and Links ### Status
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/gulp-browser)
* [gitlab.com (source)](https://gitlab.com/pushrocks/gulp-browser)
* [github.com (source mirror)](https://github.com/pushrocks/gulp-browser)
* [docs (typedoc)](https://pushrocks.gitlab.io/gulp-browser/)
## Status for master
[![build status](https://gitlab.com/pushrocks/gulp-browser/badges/master/build.svg)](https://gitlab.com/pushrocks/gulp-browser/commits/master) [![build status](https://gitlab.com/pushrocks/gulp-browser/badges/master/build.svg)](https://gitlab.com/pushrocks/gulp-browser/commits/master)
[![coverage report](https://gitlab.com/pushrocks/gulp-browser/badges/master/coverage.svg)](https://gitlab.com/pushrocks/gulp-browser/commits/master) [![Dependency Status](https://david-dm.org/pushrocks/gulp-browser.svg)](https://david-dm.org/pushrocks/gulp-browser)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/gulp-browser.svg)](https://www.npmjs.com/package/@pushrocks/gulp-browser) [![bitHound Dependencies](https://www.bithound.io/github/pushrocks/gulp-browser/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/gulp-browser/master/dependencies/npm)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/gulp-browser/badge.svg)](https://snyk.io/test/npm/@pushrocks/gulp-browser) [![bitHound Code](https://www.bithound.io/github/pushrocks/gulp-browser/badges/code.svg)](https://www.bithound.io/github/pushrocks/gulp-browser)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) [![codecov.io](https://codecov.io/github/pushrocks/gulp-browser/coverage.svg?branch=master)](https://codecov.io/github/pushrocks/gulp-browser?branch=master)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) [![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage ### Usage
gulp-browser is meant to be easy:
Use TypeScript for best in class instellisense.
#### Browserify: #### Browserify:
```typescript
```javascript let gulp = require("gulp");
let gulp = require('gulp'); let gulpBrowser = require("gulp-browser");
let gulpBrowser = require('gulp-browser');
let transforms = [ let transforms = [
{ {
transform: 'babelify', transform: "babelify",
options: { presets: ['es2015'] } options: {presets: ["es2015"]}
} }
]; ];
gulp.task('gulpBrowserTest',function() { gulp.task('gulpBrowserTest',function() {
var stream = gulp var stream = gulp.src('./test/*.js')
.src('./test/*.js')
.pipe(gulpBrowser.browserify(transforms)) // gulp.browserify() accepts an optional array of tansforms .pipe(gulpBrowser.browserify(transforms)) // gulp.browserify() accepts an optional array of tansforms
.pipe(gulp.dest('./test/browserifiedJS/')); .pipe(gulp.dest("./test/browserifiedJS/"));
return stream; return stream;
}); });
``` ```
> **Note:** Be aware of how gulp.src creates values of file.base and file.path since that is important to the require statements. > **Note:** Be aware of how gulp.src creates values of file.base and file.path since that is important to the require statements.
### Dev Information:
[![devDependency Status](https://david-dm.org/pushrocks/gulp-browser/dev-status.svg)](https://david-dm.org/pushrocks/gulp-browser#info=devDependencies)
[![bitHound Dev Dependencies](https://www.bithound.io/github/pushrocks/gulp-browser/badges/devDependencies.svg)](https://www.bithound.io/github/pushrocks/gulp-browser/master/dependencies/npm)
### Extending this module
If you have ideas for other great browser related gulp pipe stops, feel free to raise an issue on GitHub.
### Contributors ### Contributors
* [Phil Kunz](https://github.com/philkunz)
* [Steffan Donal](https://github.com/SteffanDonal)
- [Phil Kunz](https://github.com/philkunz) ### About the maintainer:
- [Steffan Donal](https://github.com/SteffanDonal) [![Project Phase](https://mediaserve.lossless.digital/lossless.com/img/createdby_github.svg)](https://lossless.com/)
For further information read the linked docs at the top of this readme. [![PayPal](https://img.shields.io/badge/Support%20us-PayPal-blue.svg)](https://paypal.me/lossless)
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

4
dist/gulpbrowser.browserify.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
/// <reference types="node" />
import * as stream from 'stream';
declare let browserify: (transforms?: any[]) => stream.Transform;
export = browserify;

43
dist/gulpbrowser.browserify.js vendored Normal file
View File

@ -0,0 +1,43 @@
"use strict";
const plugins = require("./gulpbrowser.plugins");
let browserify = function (transforms = []) {
if (!Array.isArray(transforms)) {
transforms = [transforms];
}
let forEach = function (file, enc, cb) {
let bundleCallback = function (err, bufferedContent) {
if (Buffer.isBuffer(bufferedContent)) {
file.contents = bufferedContent;
}
else {
console.log('gulp-browser: .browserify() ' + err.message);
cb(new Error(err.message), file);
return;
}
cb(null, file);
};
if (file.contents.length > 0) {
let browserified = plugins.browserify(file, { basedir: file.base });
transforms.forEach(function (transform) {
if (typeof transform === 'function') {
browserified.transform(transform);
}
else {
browserified.transform(transform.transform, transform.options);
}
});
browserified.bundle(bundleCallback);
}
else {
console.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.through2.obj(forEach, atEnd); // this is the through object that gets returned by gulpBrowser.browserify();
};
module.exports = browserify;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3VscGJyb3dzZXIuYnJvd3NlcmlmeS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2d1bHBicm93c2VyLmJyb3dzZXJpZnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUNBLGlEQUFpRDtBQUdqRCxJQUFJLFVBQVUsR0FBRyxVQUFVLFVBQVUsR0FBRyxFQUFFO0lBRXRDLEVBQUUsQ0FBQyxDQUFDLENBQUMsS0FBSyxDQUFDLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDN0IsVUFBVSxHQUFHLENBQUMsVUFBVSxDQUFDLENBQUE7SUFDN0IsQ0FBQztJQUVELElBQUksT0FBTyxHQUFHLFVBQVUsSUFBSSxFQUFFLEdBQUcsRUFBRSxFQUFFO1FBRWpDLElBQUksY0FBYyxHQUFHLFVBQVUsR0FBRyxFQUFFLGVBQWU7WUFDL0MsRUFBRSxDQUFDLENBQUMsTUFBTSxDQUFDLFFBQVEsQ0FBQyxlQUFlLENBQUMsQ0FBQy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QUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNKLE9BQU8sQ0FBQyxJQUFJLENBQUMsK0RBQStELENBQUMsQ0FBQTtZQUM3RSxFQUFFLENBQUMsSUFBSSxFQUFFLElBQUksQ0FBQyxDQUFBO1FBQ2xCLENBQUM7UUFBQSxDQUFDO0lBQ04sQ0FBQyxDQUFBO0lBRUQsSUFBSSxLQUFLLEdBQUcsVUFBVSxFQUFFO1FBQ3BCLEVBQUUsRUFBRSxDQUFBO0lBQ1IsQ0FBQyxDQUFBLENBQUMsc0NBQXNDO0lBRXhDLE1BQU0sQ0FBQyxPQUFPLENBQUMsUUFBUSxDQUFDLEdBQUcsQ0FBQyxPQUFPLEVBQUUsS0FBSyxDQUFDLENBQUEsQ0FBQyw2RUFBNkU7QUFDN0gsQ0FBQyxDQUFBO0FBRUQsaUJBQVMsVUFBVSxDQUFBIn0=

4
dist/gulpbrowser.plugins.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
import 'typings-global';
export import through2 = require('through2');
export import path = require('path');
export import browserify = require('browserify');

6
dist/gulpbrowser.plugins.js vendored Normal file
View File

@ -0,0 +1,6 @@
"use strict";
require("typings-global");
exports.through2 = require("through2");
exports.path = require("path");
exports.browserify = require("browserify");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3VscGJyb3dzZXIucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2d1bHBicm93c2VyLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2Qix1Q0FBNEM7QUFDNUMsK0JBQW9DO0FBQ3BDLDJDQUFnRCJ9

1
dist/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export import browserify = require("./gulpbrowser.browserify");

3
dist/index.js vendored Normal file
View File

@ -0,0 +1,3 @@
"use strict";
exports.browserify = require("./gulpbrowser.browserify");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEseURBQStEIn0=

View File

@ -1,19 +0,0 @@
{
"gitzone": {
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "gulp-browser",
"shortDescription": "browserify and other goodies for gulp",
"npmPackagename": "@push.rocks/gulp-browser",
"license": "MIT"
}
},
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"tsdocs": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}

4
npmts.json Normal file
View File

@ -0,0 +1,4 @@
{
"mode":"default",
"coveralls":true
}

6377
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,15 @@
{ {
"name": "@push.rocks/gulp-browser", "name": "gulp-browser",
"version": "3.0.19", "version": "3.0.3",
"private": false,
"description": "browserify and other goodies for gulp", "description": "browserify and other goodies for gulp",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(npmts)",
"build": "(tsbuild)" "reinstall": "(rm -r node_modules && npm install)",
"release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)",
"update": "(git checkout master && git pull origin master && npm install)",
"upgrade": "(npm run update) && (ncu upgradeAll && npm install)"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -15,10 +17,7 @@
}, },
"keywords": [ "keywords": [
"gulpplugin", "gulpplugin",
"browserify", "browserify"
"browser",
"TypeScript",
"typed"
], ],
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)", "author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
"license": "MIT", "license": "MIT",
@ -27,21 +26,24 @@
}, },
"homepage": "https://gitlab.com/pushrocks/gulp-browser", "homepage": "https://gitlab.com/pushrocks/gulp-browser",
"dependencies": { "dependencies": {
"@pushrocks/smartpromise": "^2.0.5", "@types/browserify": "^12.0.30",
"@types/browserify": "^12.0.36", "@types/q": "0.0.32",
"@types/through2": "^2.0.34", "@types/through2": "^2.0.32",
"browserify": "^16.2.3", "browserify": "^13.1.1",
"through2": "^3.0.0" "q": "^1.4.1",
"through2": "^2.0.3",
"typings-global": "^1.0.14"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.8", "@types/gulp": "^3.8.32",
"@gitzone/tstest": "^1.0.18", "@types/should": "^8.1.30",
"@pushrocks/gulp-function": "^3.0.1", "babel-preset-es2015": "^6.18.0",
"@pushrocks/tapbundle": "^3.0.7", "babelify": "^7.3.0",
"@types/gulp": "^4.0.5", "beautylog": "^6.0.0",
"babel-core": "^6.26.3", "gulp": "^3.9.1",
"babel-preset-es2015": "^6.24.1", "gulp-function": "^2.2.3",
"babelify": "^10.0.0", "npmts-g": "^5.2.10",
"gulp": "^4.0.0" "should": "^11.1.2",
"typings-test": "^1.0.3"
} }
} }

1
test/test.d.ts vendored Normal file
View File

@ -0,0 +1 @@
import 'typings-test';

56
test/test.js Normal file
View File

@ -0,0 +1,56 @@
"use strict";
require("typings-test");
const gulp = require("gulp");
const gulpBrowser = require("../dist/index.js");
const gulpFunction = require("gulp-function");
const q = require("q");
describe('gulpBrowser', function () {
describe('.browserify', function () {
it('should run through smoothly', function (done) {
this.timeout(30000);
let stream = gulp.src('./test/testBrowserifyNormal.js')
.pipe(gulpBrowser.browserify())
.pipe(gulp.dest('./test/result/'))
.pipe(gulpFunction.atEnd(() => {
let done2 = q.defer();
done();
done2.resolve();
return done2.promise;
}));
});
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) {
if (!doneCalled) {
done();
doneCalled = true;
}
});
d.run(function () {
let stream = gulp.src('./test/testBrowserifyError.js')
.pipe(gulpBrowser.browserify());
});
});
it('should run through with an empty file', function (done) {
let stream = gulp.src('./test/testBrowserifyEmpty.js')
.pipe(gulpBrowser.browserify())
.pipe(gulp.dest('./test/result/'))
.pipe(gulpFunction.atEnd(done));
});
it('should run through work with transforms', function (done) {
this.timeout(30000);
let transforms = [
{
transform: 'babelify',
options: { presets: ['es2015'] }
}
];
let stream = gulp.src('./test/testBrowserifyNormal.js')
.pipe(gulpBrowser.browserify(transforms))
.pipe(gulp.dest('./test/result/'))
.pipe(gulpFunction.atEnd(done));
});
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUdyQiw2QkFBNEI7QUFDNUIsZ0RBQStDO0FBQy9DLDhDQUE2QztBQUc3Qyx1QkFBc0I7QUFHdEIsUUFBUSxDQUFDLGFBQWEsRUFBRTtJQUNwQixRQUFRLENBQUMsYUFBYSxFQUFFO1FBQ3BCLEVBQUUsQ0FBQ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CAAC,CAAC,UAAU,CAAC,CAAA,CAAC;oBACZ,IAAI,EAAE,CAAC;oBACP,UAAU,GAAG,IAAI,CAAC;gBACtB,CAAC;YACL,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,GAAG,CAAC;gBACF,IAAI,MAAM,GAAG,OAAO,CAAC,IAAI,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"}

View File

@ -1,57 +1,62 @@
import * as gulp from 'gulp'; import 'typings-test'
import * as gulpFunction from '@pushrocks/gulp-function';
import * as smartpromise from '@pushrocks/smartpromise';
import { expect, tap } from '@pushrocks/tapbundle'; import * as beautylog from 'beautylog'
import * as gulp from 'gulp'
import * as gulpBrowser from '../dist/index.js'
import * as gulpFunction from 'gulp-function'
import * as gulpBrowser from '../ts/index'; import * as should from 'should'
import * as q from 'q'
tap.test('should run through smoothly', async () => {
let done = smartpromise.defer(); describe('gulpBrowser', function () {
let stream = gulp describe('.browserify', function () {
.src('./test/testBrowserifyNormal.js') it('should run through smoothly', function (done) {
this.timeout(30000)
let stream = gulp.src('./test/testBrowserifyNormal.js')
.pipe(gulpBrowser.browserify()) .pipe(gulpBrowser.browserify())
.pipe(gulp.dest('./test/result/')) .pipe(gulp.dest('./test/result/'))
.pipe( .pipe(gulpFunction.atEnd(() => {
gulpFunction.atEnd(async () => { let done2 = q.defer()
done.resolve(); done()
done2.resolve()
return done2.promise
}))
}) })
);
await done.promise;
});
tap.test('should run through with an empty file', async () => { it('should throw an error, when a module is not found', function (done) {
let done = smartpromise.defer(); let d = require('domain').create()
let stream = gulp let doneCalled = false
.src('./test/testBrowserifyEmpty.js') d.on('error',function(error){
if (!doneCalled) {
done()
doneCalled = true
}
})
d.run(function() {
let stream = gulp.src('./test/testBrowserifyError.js')
.pipe(gulpBrowser.browserify())
})
})
it('should run through with an empty file', function (done) {
let stream = gulp.src('./test/testBrowserifyEmpty.js')
.pipe(gulpBrowser.browserify()) .pipe(gulpBrowser.browserify())
.pipe(gulp.dest('./test/result/')) .pipe(gulp.dest('./test/result/'))
.pipe( .pipe(gulpFunction.atEnd(done))
gulpFunction.atEnd(async () => {
done.resolve();
}) })
); it('should run through work with transforms', function (done) {
await done.promise; this.timeout(30000)
});
tap.test('should run through work with transforms', async () => {
let done = smartpromise.defer();
let transforms = [ let transforms = [
{ {
transform: 'babelify', transform: 'babelify',
options: {presets: ['es2015']} options: {presets: ['es2015']}
} }
]; ]
let stream = gulp let stream = gulp.src('./test/testBrowserifyNormal.js')
.src('./test/testBrowserifyNormal.js')
.pipe(gulpBrowser.browserify(transforms)) .pipe(gulpBrowser.browserify(transforms))
.pipe(gulp.dest('./test/result/')) .pipe(gulp.dest('./test/result/'))
.pipe( .pipe(gulpFunction.atEnd(done))
gulpFunction.atEnd(async () => { })
done.resolve(); })
}) })
);
await done.promise;
});
tap.start();

View File

@ -1,50 +1,49 @@
import * as stream from 'stream'; import * as stream from 'stream'
import plugins = require('./gulpbrowser.plugins'); import plugins = require('./gulpbrowser.plugins')
import * as smartpromise from '@pushrocks/smartpromise'; import * as q from 'q'
let browserify = function (transforms = []) { let browserify = function (transforms = []) {
if (!Array.isArray(transforms)) { if (!Array.isArray(transforms)) {
transforms = [transforms]; transforms = [transforms]
} }
let forEach = function(file, enc, cb) { let forEach = function (file, enc, cb) { // do this with every chunk (file in gulp terms)
// do this with every chunk (file in gulp terms)
let bundleCallback = function(err, bufferedContent) { let bundleCallback = function (err, bufferedContent) { // our bundle callback for when browserify is finished
// our bundle callback for when browserify is finished
if (Buffer.isBuffer(bufferedContent)) { if (Buffer.isBuffer(bufferedContent)) {
file.contents = bufferedContent; file.contents = bufferedContent
} else { } else {
console.log('gulp-browser: .browserify() ' + err.message); console.log('gulp-browser: .browserify() ' + err.message)
cb(new Error(err.message), file); cb(new Error(err.message), file)
return; return
}
cb(null, file)
} }
cb(null, file);
};
if (file.contents.length > 0) { if (file.contents.length > 0) {
let browserified = plugins.browserify(file, { basedir: file.base }); let browserified = plugins.browserify(file, { basedir: file.base })
transforms.forEach(function (transform) { transforms.forEach(function (transform) {
if (typeof transform === 'function') { if (typeof transform === 'function') {
browserified.transform(transform); browserified.transform(transform)
} else { } else {
browserified.transform(transform.transform, transform.options); browserified.transform(transform.transform, transform.options)
} }
}); })
browserified.bundle(bundleCallback); browserified.bundle(bundleCallback)
} else { } else {
console.warn('gulp-browser: .browserify() file.contents appears to be empty'); console.warn('gulp-browser: .browserify() file.contents appears to be empty')
cb(null, file); cb(null, file)
}
}; };
}
let atEnd = function (cb) { let atEnd = function (cb) {
cb(); cb()
}; // no need to clean up after ourselves } // 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

View File

@ -1,3 +1,4 @@
export import through2 = require('through2'); import 'typings-global'
export import path = require('path'); export import through2 = require('through2')
export import browserify = require('browserify'); export import path = require('path')
export import browserify = require('browserify')

View File

@ -1 +1 @@
export import browserify = require('./gulpbrowser.browserify'); export import browserify = require("./gulpbrowser.browserify");

View File

@ -1,14 +0,0 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}

3
tslint.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "tslint-config-standard"
}