Compare commits

...

22 Commits

Author SHA1 Message Date
56b675dbbf 3.0.16 2019-02-13 00:49:53 +01:00
0aab9fcff9 fix(core): update 2019-02-13 00:49:52 +01:00
f28557c403 3.0.15 2019-02-13 00:48:37 +01:00
95fac7da7e fix(build): remove npmts 2019-02-13 00:48:36 +01:00
0d1493ca2c 3.0.14 2019-02-13 00:29:32 +01:00
de02ccb0f8 fix(core): update 2019-02-13 00:29:32 +01:00
0261ce3c31 3.0.13 2019-02-13 00:24:14 +01:00
54c655b15a fix(core): update 2019-02-13 00:24:14 +01:00
206896f552 3.0.12 2019-02-13 00:22:19 +01:00
383e204ae2 fix(core): update to latest standards 2019-02-13 00:22:18 +01:00
31f21c7dec 3.0.11 2018-03-16 10:47:10 +01:00
a96db2e036 update dependencies 2018-03-16 10:47:06 +01:00
18e2a32b8e 3.0.10 2018-03-16 10:36:37 +01:00
6784784f86 update dependencies 2018-03-16 10:36:31 +01:00
6996193568 3.0.9 2018-03-16 10:31:06 +01:00
ebc07f4c5b update dependencies 2018-03-16 10:31:01 +01:00
088a5e6fe5 3.0.8 2018-03-15 01:21:25 +01:00
04345d1691 fix typo 2018-03-15 01:21:13 +01:00
ab6870a193 3.0.7 2018-03-15 00:33:50 +01:00
d1486c2bef update to latest Standards 2018-03-15 00:33:43 +01:00
87e684aa7b 3.0.6 2017-07-07 18:35:25 +02:00
9c31773f31 update docs 2017-07-07 18:35:20 +02:00
20 changed files with 6638 additions and 2992 deletions

1
.gitignore vendored
View File

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

View File

@ -3,66 +3,144 @@ image: hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
- .yarn/ - .npmci_cache/
key: "$CI_BUILD_STAGE" key: "$CI_BUILD_STAGE"
stages: stages:
- security
- test - test
- release - release
- trigger - metadata
- pages
testLEGACY: # ====================
stage: test # security stage
# ====================
mirror:
stage: security
script: script:
- npmci test legacy - npmci git mirror
coverage: /\d+.?\d+?\%\s*coverage/
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 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 test lts - npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
testSTABLE: testSTABLE:
stage: test stage: test
script: script:
- npmci test stable - npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
release: release:
stage: release stage: release
script: script:
- npmci publish - npmci node install stable
- npmci npm publish
only: only:
- tags - tags
tags: tags:
- docker - 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: trigger:
stage: trigger stage: metadata
script: script:
- npmci trigger - npmci trigger
only: only:
- tags - tags
tags: tags:
- docker - docker
- notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmci image: hosttoday/ht-docker-node:npmci
stage: pages stage: metadata
script: script:
- npmci command yarn global add npmpage - npmci command npm install -g typedoc typescript
- npmci command npmpage - npmci npm prepare
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
tags: tags:
- docker - docker
- notpriv
only: only:
- tags - tags
artifacts: artifacts:

4
.snyk Normal file
View File

@ -0,0 +1,4 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.13.3
ignore: {}
patch: {}

View File

@ -1,6 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2015 Push.Rocks Copyright (c) 2015 Lossless GmbH
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,50 +1,57 @@
# gulp-browser # @pushrocks/gulp-browser
browserify and other goodies for gulp browserify and other goodies for gulp
## Availabililty ## Availabililty and Links
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/gulp-browser) * [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/gulp-browser)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/gulp-browser) * [gitlab.com (source)](https://gitlab.com/pushrocks/gulp-browser)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/gulp-browser) * [github.com (source mirror)](https://github.com/pushrocks/gulp-browser)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/gulp-browser/) * [docs (typedoc)](https://pushrocks.gitlab.io/gulp-browser/)
## Status for master ## 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) [![coverage report](https://gitlab.com/pushrocks/gulp-browser/badges/master/coverage.svg)](https://gitlab.com/pushrocks/gulp-browser/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/gulp-browser.svg)](https://www.npmjs.com/package/gulp-browser) [![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/gulp-browser.svg)](https://www.npmjs.com/package/@pushrocks/gulp-browser)
[![Dependency Status](https://david-dm.org/pushrocks/gulp-browser.svg)](https://david-dm.org/pushrocks/gulp-browser) [![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/gulp-browser/badge.svg)](https://snyk.io/test/npm/@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) [![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![bitHound Code](https://www.bithound.io/github/pushrocks/gulp-browser/badges/code.svg)](https://www.bithound.io/github/pushrocks/gulp-browser) [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.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/) [![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage ## Usage
Use TypeScript for best in class instellisense. Use TypeScript for best in class instellisense.
#### Browserify: #### Browserify:
```javascript ```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.src('./test/*.js') var stream = gulp
.pipe(gulpBrowser.browserify(transforms)) // gulp.browserify() accepts an optional array of tansforms .src('./test/*.js')
.pipe(gulp.dest("./test/browserifiedJS/")); .pipe(gulpBrowser.browserify(transforms)) // gulp.browserify() accepts an optional array of tansforms
return stream; .pipe(gulp.dest('./test/browserifiedJS/'));
}); 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.
### Contributors ### Contributors
* [Phil Kunz](https://github.com/philkunz)
* [Steffan Donal](https://github.com/SteffanDonal)
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks) - [Phil Kunz](https://github.com/philkunz)
- [Steffan Donal](https://github.com/SteffanDonal)
For further information read the linked docs at the top of this readme.
> 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)

View File

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

View File

@ -1,43 +0,0 @@
"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3VscGJyb3dzZXIuYnJvd3NlcmlmeS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2d1bHBicm93c2VyLmJyb3dzZXJpZnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUNBLGlEQUFpRDtBQUdqRCxJQUFJLFVBQVUsR0FBRyxVQUFVLFVBQVUsR0FBRyxFQUFFO0lBRXRDLEVBQUUsQ0FBQyxDQUFDLENBQUMsS0FBSyxDQUFDLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDN0IsVUFBVSxHQUFHLENBQUMsVUFBVSxDQUFDLENBQUE7SUFDN0IsQ0FBQztJQUVELElBQUksT0FBTyxHQUFHLFVBQVUsSUFBSSxFQUFFLEdBQUcsRUFBRSxFQUFFO1FBRWpDLElBQUksY0FBYyxHQUFHLFVBQVUsR0FBRyxFQUFFLGVBQWU7WUFDL0MsRUFBRSxDQUFDLENBQUMsTUFBTSxDQUFDLFFBQVEsQ0FBQyxlQUFlLENBQUMsQ0FBQyxDQUFDLENBQUM7Z0JBQ25DLElBQUksQ0FBQyxRQUFRLEdBQUcsZUFBZSxDQUFBO1lBQ25DLENBQUM7WUFBQyxJQUFJLENBQUMsQ0FBQztnQkFDSixPQUFPLENBQUMsR0FBRyxDQUFDLDhCQUE4QixHQUFHLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQTtnQkFDekQsRUFBRSxDQUFDLElBQUksS0FBSyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsRUFBRSxJQUFJLENBQUMsQ0FBQTtnQkFDaEMsTUFBTSxDQUFBO1lBQ1YsQ0FBQztZQUNELEVBQUUsQ0FBQyxJQUFJLEVBQUUsSUFBSSxDQUFDLENBQUE7UUFDbEIsQ0FBQyxDQUFBO1FBRUQsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLFFBQVEsQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDLENBQUMsQ0FBQztZQUMzQixJQUFJLFlBQVksR0FBRyxPQUFPLENBQUMsVUFBVSxDQUFDLElBQUksRUFBRSxFQUFFLE9BQU8sRUFBRSxJQUFJLENBQUMsSUFBSSxFQUFFLENBQUMsQ0FBQTtZQUVuRSxVQUFVLENBQUMsT0FBTyxDQUFDLFVBQVUsU0FBUztnQkFDbEMsRUFBRSxDQUFDLENBQUMsT0FBTyxTQUFTLEtBQUssVUFBVSxDQUFDLENBQUMsQ0FBQztvQkFDbEMsWUFBWSxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUMsQ0FBQTtnQkFDckMsQ0FBQztnQkFBQyxJQUFJLENBQUMsQ0FBQztvQkFDSixZQUFZLENBQUMsU0FBUyxDQUFDLFNBQVMsQ0FBQyxTQUFTLEVBQUUsU0FBUyxDQUFDLE9BQU8sQ0FBQyxDQUFBO2dCQUNsRSxDQUFDO1lBQ0wsQ0FBQyxDQUFDLENBQUE7WUFFRixZQUFZLENBQUMsTUFBTSxDQUFDLGNBQWMsQ0FBQyxDQUFBO1FBQ3ZDLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNKLE9BQU8sQ0FBQyxJQUFJLENBQUMsK0RBQStELENBQUMsQ0FBQTtZQUM3RSxFQUFFLENBQUMsSUFBSSxFQUFFLElBQUksQ0FBQyxDQUFBO1FBQ2xCLENBQUM7UUFBQSxDQUFDO0lBQ04sQ0FBQyxDQUFBO0lBRUQsSUFBSSxLQUFLLEdBQUcsVUFBVSxFQUFFO1FBQ3BCLEVBQUUsRUFBRSxDQUFBO0lBQ1IsQ0FBQyxDQUFBLENBQUMsc0NBQXNDO0lBRXhDLE1BQU0sQ0FBQyxPQUFPLENBQUMsUUFBUSxDQUFDLEdBQUcsQ0FBQyxPQUFPLEVBQUUsS0FBSyxDQUFDLENBQUEsQ0FBQyw2RUFBNkU7QUFDN0gsQ0FBQyxDQUFBO0FBRUQsaUJBQVMsVUFBVSxDQUFBIn0=

View File

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

View File

@ -1,7 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global");
exports.through2 = require("through2");
exports.path = require("path");
exports.browserify = require("browserify");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3VscGJyb3dzZXIucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2d1bHBicm93c2VyLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwQkFBdUI7QUFDdkIsdUNBQTRDO0FBQzVDLCtCQUFvQztBQUNwQywyQ0FBZ0QifQ==

1
dist/index.d.ts vendored
View File

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

4
dist/index.js vendored
View File

@ -1,4 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.browserify = require("./gulpbrowser.browserify");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHlEQUE4RCJ9

View File

@ -1,7 +1,5 @@
{ {
"npmci": { "npmci": {
"globalNpmTools": [ "npmGlobalTools": []
"npmts"
]
} }
} }

6377
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,13 @@
{ {
"name": "gulp-browser", "name": "@pushrocks/gulp-browser",
"version": "3.0.5", "version": "3.0.16",
"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": "(npmts)", "test": "(tstest test/)",
"reinstall": "(rm -r node_modules && npm install)", "build": "(tsbuild)"
"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",
@ -29,22 +27,21 @@
}, },
"homepage": "https://gitlab.com/pushrocks/gulp-browser", "homepage": "https://gitlab.com/pushrocks/gulp-browser",
"dependencies": { "dependencies": {
"@types/browserify": "^12.0.32", "@pushrocks/smartpromise": "^2.0.5",
"@types/q": "1.0.2", "@types/browserify": "^12.0.36",
"@types/through2": "^2.0.33", "@types/through2": "^2.0.34",
"browserify": "^14.4.0", "browserify": "^16.2.3",
"q": "^1.5.0", "through2": "^3.0.0"
"smartq": "^1.1.6",
"through2": "^2.0.3",
"typings-global": "^1.0.19"
}, },
"devDependencies": { "devDependencies": {
"@types/gulp": "^4.0.4", "@gitzone/tsbuild": "^2.1.8",
"@gitzone/tstest": "^1.0.18",
"@pushrocks/gulp-function": "^3.0.1",
"@pushrocks/tapbundle": "^3.0.7",
"@types/gulp": "^4.0.5",
"babel-core": "^6.26.3",
"babel-preset-es2015": "^6.24.1", "babel-preset-es2015": "^6.24.1",
"babelify": "^7.3.0", "babelify": "^10.0.0",
"beautylog": "^6.1.10", "gulp": "^4.0.0"
"gulp": "^3.9.1",
"gulp-function": "^2.2.9",
"tapbundle": "^1.1.0"
} }
} }

View File

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

View File

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

View File

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

View File

@ -1,3 +1,17 @@
{ {
"extends": "tslint-config-standard" "extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
} }

2756
yarn.lock

File diff suppressed because it is too large Load Diff