update to latest Standards

This commit is contained in:
Philipp Kunz 2018-03-15 00:33:43 +01:00
parent 87e684aa7b
commit d1486c2bef
15 changed files with 1210 additions and 855 deletions

View File

@ -7,53 +7,77 @@ cache:
key: "$CI_BUILD_STAGE"
stages:
- security
- test
- release
- trigger
- pages
mirror:
stage: security
script:
- npmci git mirror
tags:
- docker
snyk:
stage: security
script:
- npmci command yarn global add snyk
- npmci command yarn install --ignore-scripts
- npmci command snyk test
tags:
- docker
testLEGACY:
stage: test
script:
- npmci test legacy
- npmci node install legacy
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- docker
allow_failure: true
testLTS:
stage: test
script:
- npmci test lts
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- docker
testSTABLE:
stage: test
script:
- npmci test stable
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- docker
release:
stage: release
script:
- npmci publish
- npmci npm prepare
- npmci npm publish
only:
- tags
- tags
tags:
- docker
- docker
trigger:
stage: trigger
script:
- npmci trigger
- npmci trigger
only:
- tags
- tags
tags:
- docker
- docker
pages:
image: hosttoday/ht-docker-node:npmci
@ -69,4 +93,3 @@ pages:
expire_in: 1 week
paths:
- public
allow_failure: true

View File

@ -1,13 +1,16 @@
# gulp-browser
browserify and other goodies for gulp
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/gulp-browser)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/gulp-browser)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/gulp-browser)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](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)
[![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)
@ -19,38 +22,41 @@ browserify and other goodies for gulp
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
Use TypeScript for best in class instellisense.
#### 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;
});
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;
});
```
> **Note:** Be aware of how gulp.src creates values of file.base and file.path since that is important to the require statements.
### Contributors
* [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)
> | 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://push.rocks)

View File

@ -5,7 +5,9 @@ let browserify = function (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;
}
@ -32,7 +34,6 @@ let browserify = function (transforms = []) {
console.warn('gulp-browser: .browserify() file.contents appears to be empty');
cb(null, file);
}
;
};
let atEnd = function (cb) {
cb();
@ -40,4 +41,4 @@ let browserify = function (transforms = []) {
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3VscGJyb3dzZXIuYnJvd3NlcmlmeS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2d1bHBicm93c2VyLmJyb3dzZXJpZnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUNBLGlEQUFpRDtBQUdqRCxJQUFJLFVBQVUsR0FBRyxVQUFVLFVBQVUsR0FBRyxFQUFFO0lBRXRDLEVBQUUsQ0FBQyxDQUFDLENBQUMsS0FBSyxDQUFDLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDN0IsVUFBVSxHQUFHLENBQUMsVUFBVSxDQUFDLENBQUE7SUFDN0IsQ0FBQztJQUVELElBQUksT0FBTyxHQUFHLFVBQVUsSUFBSSxFQUFFLEdBQUcsRUFBRSxFQUFFO1FBRWpDLElBQUksY0FBYyxHQUFHLFVBQVUsR0FBRyxFQUFFLGVBQWU7WUFDL0MsRUFBRSxDQUFDLENBQUMsTUFBTSxDQUFDLFFBQVEsQ0FBQyxlQUFlLENBQUMsQ0FBQyxDQUFDLENBQUM7Z0JBQ25DLElBQUksQ0FBQyxRQUFRLEdBQUcsZUFBZSxDQUFBO1lBQ25DLENBQUM7WUFBQyxJQUFJLENBQUMsQ0FBQztnQkFDSixPQUFPLENBQUMsR0FBRyxDQUFDLDhCQUE4QixHQUFHLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQTtnQkFDekQsRUFBRSxDQUFDLElBQUksS0FBSyxDQUFDLEd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FBQztJQUNILENBQUMsQ0FBQztJQUVGLElBQUksS0FBSyxHQUFHLFVBQVMsRUFBRTtRQUNyQixFQUFFLEVBQUUsQ0FBQztJQUNQLENBQUMsQ0FBQyxDQUFDLHNDQUFzQztJQUV6QyxNQUFNLENBQUMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxHQUFHLENBQUMsT0FBTyxFQUFFLEtBQUssQ0FBQyxDQUFDLENBQUMsNkVBQTZFO0FBQzVILENBQUMsQ0FBQztBQUVGLGlCQUFTLFVBQVUsQ0FBQyJ9

View File

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

View File

@ -1,7 +1,6 @@
"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==
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3VscGJyb3dzZXIucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL2d1bHBicm93c2VyLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx1Q0FBNkM7QUFDN0MsK0JBQXFDO0FBQ3JDLDJDQUFpRCJ9

2
dist/index.d.ts vendored
View File

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

2
dist/index.js vendored
View File

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

View File

@ -1,56 +0,0 @@
# gulp-browser
browserify and other goodies for gulp
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/gulp-browser)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/gulp-browser)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/gulp-browser)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](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)
[![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)
[![Dependency Status](https://david-dm.org/pushrocks/gulp-browser.svg)](https://david-dm.org/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)
[![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-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/)
## Usage
Use TypeScript for best in class instellisense.
#### 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;
});
```
> **Note:** Be aware of how gulp.src creates values of file.base and file.path since that is important to the require statements.
### Contributors
* [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://push.rocks)

View File

@ -1,6 +1,6 @@
{
"npmci": {
"globalNpmTools": [
"npmGlobalpmTools": [
"npmts"
]
}

View File

@ -30,21 +30,21 @@
"homepage": "https://gitlab.com/pushrocks/gulp-browser",
"dependencies": {
"@types/browserify": "^12.0.32",
"@types/q": "1.0.2",
"@types/q": "1.0.7",
"@types/through2": "^2.0.33",
"browserify": "^14.4.0",
"browserify": "^16.1.1",
"q": "^1.5.0",
"smartq": "^1.1.6",
"through2": "^2.0.3",
"typings-global": "^1.0.19"
"through2": "^2.0.3"
},
"devDependencies": {
"@types/gulp": "^4.0.4",
"babel-core": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babelify": "^7.3.0",
"babelify": "^8.0.0",
"beautylog": "^6.1.10",
"gulp": "^3.9.1",
"gulp-function": "^2.2.9",
"tapbundle": "^1.1.0"
"tapbundle": "^2.0.0"
}
}

View File

@ -1,66 +1,74 @@
import * as beautylog from 'beautylog'
import * as gulp from 'gulp'
import * as gulpFunction from 'gulp-function'
import * as smartq from 'smartq'
import * as beautylog from 'beautylog';
import * as gulp from 'gulp';
import * as gulpFunction from 'gulp-function';
import * as smartq from 'smartq';
import { expect, tap } from 'tapbundle'
import { expect, tap } from 'tapbundle';
import * as gulpBrowser from '../dist/index.js'
import * as gulpBrowser from '../ts/index';
tap.test('should run through smoothly', async () => {
let done = smartq.defer()
let stream = gulp.src('./test/testBrowserifyNormal.js')
let done = smartq.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
})
.pipe(
gulpFunction.atEnd(async () => {
done.resolve();
})
);
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) {
let done = smartq.defer();
let d = require('domain').create();
let doneCalled = false;
d.on('error', function(error) {
if (!doneCalled) {
done.resolve()
doneCalled = true
done.resolve();
doneCalled = true;
}
})
d.run(function () {
let stream = gulp.src('./test/testBrowserifyError.js')
.pipe(gulpBrowser.browserify())
})
await done.promise
})
});
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 () => {
let done = smartq.defer()
let stream = gulp.src('./test/testBrowserifyEmpty.js')
let done = smartq.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
})
.pipe(
gulpFunction.atEnd(async () => {
done.resolve();
})
);
await done.promise;
});
tap.test('should run through work with transforms', async () => {
let done = smartq.defer()
let done = smartq.defer();
let transforms = [
{
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(gulp.dest('./test/result/'))
.pipe(gulpFunction.atEnd(async () => {
done.resolve()
}))
await done.promise
})
.pipe(
gulpFunction.atEnd(async () => {
done.resolve();
})
);
await done.promise;
});
tap.start()
tap.start();

View File

@ -1,49 +1,50 @@
import * as stream from 'stream'
import plugins = require('./gulpbrowser.plugins')
import * as q from 'q'
import * as stream from 'stream';
import plugins = require('./gulpbrowser.plugins');
import * as q from 'q';
let browserify = function (transforms = []) {
let browserify = function(transforms = []) {
if (!Array.isArray(transforms)) {
transforms = [transforms];
}
if (!Array.isArray(transforms)) {
transforms = [transforms]
}
let forEach = function(file, enc, cb) {
// 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 (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 });
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)
transforms.forEach(function(transform) {
if (typeof transform === 'function') {
browserified.transform(transform);
} else {
console.warn('gulp-browser: .browserify() file.contents appears to be empty')
cb(null, file)
};
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
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();
}
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 path = require('path')
export import browserify = require('browserify')
export import through2 = require('through2');
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');

1709
yarn.lock

File diff suppressed because it is too large Load Diff