Compare commits
No commits in common. "master" and "v1.0.7" have entirely different histories.
12
.gitignore
vendored
12
.gitignore
vendored
@ -1,6 +1,10 @@
|
||||
node_modules/
|
||||
.settings/
|
||||
.idea/
|
||||
npm-debug.log
|
||||
test/result/
|
||||
coverage/
|
||||
pages/
|
||||
public
|
||||
|
||||
ts/*.js
|
||||
ts/*.js.map
|
||||
ts/typings/
|
||||
|
||||
test/result/
|
150
.gitlab-ci.yml
150
.gitlab-ci.yml
@ -1,150 +0,0 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
tags:
|
||||
- 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:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- 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
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- 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
|
@ -1,4 +1,3 @@
|
||||
node_modules
|
||||
test
|
||||
ts
|
||||
coverage/
|
||||
ts
|
14
.travis.yml
Normal file
14
.travis.yml
Normal file
@ -0,0 +1,14 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '4.2.4'
|
||||
deploy:
|
||||
provider: npm
|
||||
email: npm@lossless.digital
|
||||
api_key:
|
||||
secure: MNBFCPscAm1+rY1qIHbye3Bwif9W/bPyHxvXyoKbi8G2URQjZKNYTpRT0bVShj6UBJihBrnXa40cxmU/F+rcQhPeY4uFIC5oBIyYkSrn0XvhJEqn/yQnBl0DrdImYSuYx480jLKvvNq3RIft2K+5y6+qb8QuumV/1p4QYbiM6Ibwz54SPfmJtzsMsei8bHzbDvOtKeoX8l3mGqyIVX1D/Nnnq9rH0UZnbqf7W5IH/QlCTpVAj5v/HRCSbCbJkbmwTYtx4PV0xS9vYgXklwFr0FcJXyZPmzqSRM/EYnhOg61uQCWM1JG12nDmdv8lkE+x5L6fV+YXTeBAKmnCBAZy8D7CYX0jDELrpKp4wKFofl/AkTDAlVsjEb4U+DVXuJOWt8KQzjYGLX6nXXOUzDD9OXNmB6010a2g3SQ4vCX3jHomycPZTgKPd4MN5xiJBfg/EXn1HlJdtO8jYFB2S87VVmFrJfwQ6x4iZxabmWPtasye3DP/OLX+8/8aWNGLMjP/Lr4muPS4B9OOlI3EvVo+DR3B381NPwzKaM9NLkeM3pHgMhm0K2mqOnbvhUhhkmmMkQI1T+RRf91zraPXAh7fMRDh2lDqKfrhtKobFBmONgXAtO7QPz2Bhp+kszwRo/Vx//H2VpUD45CNfMKnN99VYY/FHGYICBYH2mK/MX50HAA=
|
||||
on:
|
||||
tags: true
|
||||
repo: pushrocks/gulp-browser
|
||||
notifications:
|
||||
slack:
|
||||
secure: f5Uss0z9RPl/QcA/DroB8loyE93aOYI6bqCkrsiUscmZtlv/TVQtT4dxqGA6uvcG6iTQDBi3Ul88dQxWkRm4IqbhY35/iMaV2dHW4FVYMAh8GQMbsfL2sALCcufxD9blw47awv3iFcwhV1EeyesscjgL0JIjduk96v/7G/6QIO2838M1lzlgtj+kRUkim8qkaEs1je3gRrhMUIjLuAdscMXyUKYFMjWo9ACSjVUl30R/ZNemb18itIja6i92GotreBgcfEMczvy58ovDC7xdJUsY8LjMI01DwY+WPRnI0tAhsuI8moBwwcdM4e3bAjKjucQRjO33O5bMWRZ6QCiYd0DnCEFyCPQLJ4GSy/tkD00n8ijLHAOSV3AH1zNbdK1EAdSPQXDvlI36KJn/2hyQLoitGHVUPr76ujJWP82ypO2tgIp3XQU0dJVCxDuHnwJO2+hjdI+gCPqxNTpjeujHx3UdkTGNRjuuf9dlZ/D08fApjYxy2fxItTqo3QjP/nrqvBXUOPP8yPHpjIT4H2t5Pr4SJjBGI6X4qhKyFj6s9rA/Xu1rL+45zu1C3uC3z+u3T9UwrbzJ/cZM6r6UQvQmUvIfBNaMlg4I/diQCDIPL+Rhop2nylY3IcHmJnk2itn7kOqj1tohCpFEml5pRuSZy4udWywkdtyBAsHWFLF7oiQ=
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
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
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
67
README.md
67
README.md
@ -1,57 +1,36 @@
|
||||
# @pushrocks/gulp-browser
|
||||
# gulp-browser
|
||||
browserify and other goodies for gulp
|
||||
|
||||
## Availabililty and Links
|
||||
* [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/)
|
||||
### Build Status/Dependencies
|
||||
[](https://travis-ci.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)
|
||||
|
||||
## Status for master
|
||||
[](https://gitlab.com/pushrocks/gulp-browser/commits/master)
|
||||
[](https://gitlab.com/pushrocks/gulp-browser/commits/master)
|
||||
[](https://www.npmjs.com/package/@pushrocks/gulp-browser)
|
||||
[](https://snyk.io/test/npm/@pushrocks/gulp-browser)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
### Usage
|
||||
gulp-browser is meant to be easy:
|
||||
|
||||
#### Browserify:
|
||||
|
||||
```javascript
|
||||
let gulp = require('gulp');
|
||||
let gulpBrowser = require('gulp-browser');
|
||||
|
||||
let transforms = [
|
||||
{
|
||||
transform: 'babelify',
|
||||
options: { presets: ['es2015'] }
|
||||
}
|
||||
];
|
||||
|
||||
gulp.task('gulpBrowserTest', function() {
|
||||
var stream = gulp
|
||||
.src('./test/*.js')
|
||||
.pipe(gulpBrowser.browserify(transforms)) // gulp.browserify() accepts an optional array of tansforms
|
||||
.pipe(gulp.dest('./test/browserifiedJS/'));
|
||||
return stream;
|
||||
});
|
||||
var gulp = require("gulp");
|
||||
var gulpBrowser = require("gulp-browser");
|
||||
|
||||
gulp.task('gulpBrowserTest',function() {
|
||||
var stream = gulp.src('./test/*.js')
|
||||
.pipe(gulpBrowser.browserify())
|
||||
.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.
|
||||
|
||||
### Contributors
|
||||
### Dev Information:
|
||||
[](https://david-dm.org/pushrocks/gulp-browser#info=devDependencies)
|
||||
[](https://www.bithound.io/github/pushrocks/gulp-browser/master/dependencies/npm)
|
||||
|
||||
- [Phil Kunz](https://github.com/philkunz)
|
||||
- [Steffan Donal](https://github.com/SteffanDonal)
|
||||
### About the authors:
|
||||
[](https://lossless.com/)
|
||||
|
||||
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)
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
[](https://paypal.me/lossless)
|
12
index.d.ts
vendored
Normal file
12
index.d.ts
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
/// <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
Normal file
37
index.js
Normal file
@ -0,0 +1,37 @@
|
||||
#!/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;
|
@ -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"
|
||||
}
|
||||
}
|
6377
package-lock.json
generated
6377
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
49
package.json
49
package.json
@ -1,47 +1,38 @@
|
||||
{
|
||||
"name": "@push.rocks/gulp-browser",
|
||||
"version": "3.0.19",
|
||||
"private": false,
|
||||
"name": "gulp-browser",
|
||||
"version": "1.0.7",
|
||||
"description": "browserify and other goodies for gulp",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)"
|
||||
"test": "(npmts)",
|
||||
"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": {
|
||||
"type": "git",
|
||||
"url": "https://gitlab.com/pushrocks/gulp-browser.git"
|
||||
"url": "https://github.com/pushrocks/gulp-browser.git"
|
||||
},
|
||||
"keywords": [
|
||||
"gulpplugin",
|
||||
"browserify",
|
||||
"browser",
|
||||
"TypeScript",
|
||||
"typed"
|
||||
"browserify"
|
||||
],
|
||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/pushrocks/gulp-browser/issues"
|
||||
"url": "https://github.com/pushrocks/gulp-browser/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/gulp-browser",
|
||||
"homepage": "https://github.com/pushrocks/gulp-browser",
|
||||
"dependencies": {
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@types/browserify": "^12.0.36",
|
||||
"@types/through2": "^2.0.34",
|
||||
"browserify": "^16.2.3",
|
||||
"through2": "^3.0.0"
|
||||
"beautylog": "2.0.6",
|
||||
"browserify": "13.0.0",
|
||||
"gulp-util": "3.0.7",
|
||||
"through2": "2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@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",
|
||||
"babelify": "^10.0.0",
|
||||
"gulp": "^4.0.0"
|
||||
"gulp": "3.9.0",
|
||||
"gulp-function": "1.0.2",
|
||||
"npmts": "^2.0.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
29
test/test.js
Normal file
29
test/test.js
Normal file
@ -0,0 +1,29 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
var plugins = {
|
||||
beautylog: require("beautylog"),
|
||||
gulp: require("gulp"),
|
||||
gulpBrowser: require("../index.js"),
|
||||
gulpFunction: require("gulp-function")
|
||||
};
|
||||
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.gulpFunction(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;
|
||||
});
|
57
test/test.ts
57
test/test.ts
@ -1,57 +0,0 @@
|
||||
import * as gulp from 'gulp';
|
||||
import * as gulpFunction from '@pushrocks/gulp-function';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
|
||||
import * as gulpBrowser from '../ts/index';
|
||||
|
||||
tap.test('should run through smoothly', async () => {
|
||||
let done = smartpromise.defer();
|
||||
let stream = gulp
|
||||
.src('./test/testBrowserifyNormal.js')
|
||||
.pipe(gulpBrowser.browserify())
|
||||
.pipe(gulp.dest('./test/result/'))
|
||||
.pipe(
|
||||
gulpFunction.atEnd(async () => {
|
||||
done.resolve();
|
||||
})
|
||||
);
|
||||
await done.promise;
|
||||
});
|
||||
|
||||
tap.test('should run through with an empty file', async () => {
|
||||
let done = smartpromise.defer();
|
||||
let stream = gulp
|
||||
.src('./test/testBrowserifyEmpty.js')
|
||||
.pipe(gulpBrowser.browserify())
|
||||
.pipe(gulp.dest('./test/result/'))
|
||||
.pipe(
|
||||
gulpFunction.atEnd(async () => {
|
||||
done.resolve();
|
||||
})
|
||||
);
|
||||
await done.promise;
|
||||
});
|
||||
|
||||
tap.test('should run through work with transforms', async () => {
|
||||
let done = smartpromise.defer();
|
||||
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(async () => {
|
||||
done.resolve();
|
||||
})
|
||||
);
|
||||
await done.promise;
|
||||
});
|
||||
|
||||
tap.start();
|
@ -1,50 +0,0 @@
|
||||
import * as stream from 'stream';
|
||||
import plugins = require('./gulpbrowser.plugins');
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
|
||||
let browserify = function(transforms = []) {
|
||||
if (!Array.isArray(transforms)) {
|
||||
transforms = [transforms];
|
||||
}
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
export = browserify;
|
@ -1,3 +0,0 @@
|
||||
export import through2 = require('through2');
|
||||
export import path = require('path');
|
||||
export import browserify = require('browserify');
|
19
ts/index.ts
19
ts/index.ts
@ -1 +1,18 @@
|
||||
export import browserify = require('./gulpbrowser.browserify');
|
||||
/// <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:any = {};
|
||||
|
||||
gulpBrowser.browserify = GulpBrowserBrowserify.init();
|
||||
|
||||
module.exports = gulpBrowser;
|
||||
|
19
ts/modulebrowserify.ts
Normal file
19
ts/modulebrowserify.ts
Normal file
@ -0,0 +1,19 @@
|
||||
/// <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
Normal file
31
ts/test.ts
Normal file
@ -0,0 +1,31 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
var plugins = {
|
||||
beautylog: require("beautylog"),
|
||||
gulp: require("gulp"),
|
||||
gulpBrowser: require("../index.js"),
|
||||
gulpFunction: require("gulp-function")
|
||||
};
|
||||
|
||||
describe("gulpBrowser",function(){
|
||||
describe(".browserify",function(){
|
||||
it("should run through smoothly",function(done){
|
||||
this.timeout(20000);
|
||||
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.gulpFunction(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
Normal file
15
ts/tsd.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
7
ts/typings.json
Normal file
7
ts/typings.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"ambientDependencies": {
|
||||
"browserify": "github:DefinitelyTyped/DefinitelyTyped/browserify/browserify.d.ts",
|
||||
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
||||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts"
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user