Compare commits

...

47 Commits

Author SHA1 Message Date
edcb1d114f update description 2024-05-29 14:11:02 +02:00
3ba5685914 update tsconfig 2024-04-14 13:35:59 +02:00
cb0f810201 update npmextra.json: githost 2024-04-01 21:33:06 +02:00
94a5d3022e update npmextra.json: githost 2024-04-01 19:57:21 +02:00
919fcfd9f5 update npmextra.json: githost 2024-03-30 21:46:17 +01:00
660ffd8880 3.0.7 2024-03-10 23:30:24 +01:00
1744e9b338 fix(core): update 2024-03-10 23:30:23 +01:00
b738a360cc 3.0.6 2024-03-10 23:29:57 +01:00
0c703cb5c3 fix(core): update 2024-03-10 23:29:56 +01:00
27ee7a532a switch to new org scheme 2023-07-10 23:58:45 +02:00
29d439ce0d switch to new org scheme 2023-07-10 02:41:17 +02:00
faa4bb88a8 3.0.5 2023-06-30 15:50:09 +02:00
a95319d99f fix(core): update 2023-06-30 15:50:08 +02:00
e7c0e1228b 3.0.4 2020-01-18 16:35:55 +00:00
9586f34d64 fix(core): update 2020-01-18 16:35:55 +00:00
6300845ec8 3.0.3 2020-01-18 12:19:49 +00:00
2316a983ed fix(core): update 2020-01-18 12:19:48 +00:00
a1fa6b751e 3.0.2 2020-01-18 12:19:28 +00:00
5792a13b01 fix(core): update 2020-01-18 12:19:27 +00:00
1008c3f103 3.0.1 2018-12-09 01:34:30 +01:00
c366bde211 fix(npm): permissions 2018-12-09 01:34:30 +01:00
e22c6764b7 3.0.0 2018-12-09 01:27:25 +01:00
50836eab06 BREAKING CHANGE(npm scope): update 2018-12-09 01:27:24 +01:00
077834f7a4 2.2.16 2018-12-09 01:19:44 +01:00
ca348b5475 fix(license): switch to company name from brand name 2018-12-09 01:19:44 +01:00
2c9ab52cee 2.2.15 2018-12-09 01:19:02 +01:00
7d35f4c90b fix(core): update to latest gitzone standards 2018-12-09 01:19:01 +01:00
Phil Kunz
a05253bdcd Merge branch 'patch-1' into 'master'
Fix sample code in README.md

See merge request pushrocks/gulp-function!2
2018-12-09 00:08:24 +00:00
ulrichb
54b80098d2 Fix sample code in README.md 2018-12-08 18:57:10 +00:00
c39a4a6cb0 2.2.14 2018-01-29 23:54:02 +01:00
f325479a11 update ci 2018-01-29 23:53:58 +01:00
c79f443c18 2.2.13 2018-01-29 23:30:12 +01:00
14bb4a90bb update README 2018-01-29 23:30:09 +01:00
98a583bae1 2.2.12 2018-01-29 23:28:06 +01:00
848d9ac1e0 update to latest standards 2018-01-29 23:28:03 +01:00
e7ccd9aec4 2.2.11 2017-10-27 12:49:45 +02:00
63bf7204dd update 2017-10-27 12:49:43 +02:00
a34a1b89fe 2.2.10 2017-09-07 22:33:43 +02:00
f4455a9b91 update dependencies 2017-09-07 22:33:40 +02:00
1a01198d7f 2.2.9 2017-04-30 17:28:18 +02:00
b3ec364a1d 2.2.8 2017-04-30 17:23:26 +02:00
5d15c96511 update docs and .gitignore 2017-04-30 17:23:22 +02:00
f6e071156b 2.2.7 2017-04-30 17:11:50 +02:00
63fe7c7423 update README 2017-04-30 17:11:40 +02:00
c8dcdc0df4 update README 2017-04-30 17:11:19 +02:00
743c7a03a5 2.2.6 2017-04-30 01:07:35 +02:00
f9e7bf450b now cleans pipe correctly 2017-04-30 01:07:30 +02:00
41 changed files with 8156 additions and 1622 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

23
.gitignore vendored
View File

@ -1,13 +1,20 @@
node_modules/
.settings/
.idea/
.nogit/
# artifacts
coverage/
docs/
public/
pages/
ts/*.js
ts/*.js.map
ts/typings/
test/result/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,71 +0,0 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
cache:
paths:
- .yarn/
key: "$CI_BUILD_STAGE"
stages:
- test
- release
- trigger
- pages
testLEGACY:
stage: test
script:
- npmci test legacy
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
allow_failure: true
testLTS:
stage: test
script:
- npmci test lts
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testSTABLE:
stage: test
script:
- npmci test stable
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
script:
- npmci publish
only:
- tags
tags:
- docker
trigger:
stage: trigger
script:
- npmci trigger
only:
- tags
tags:
- docker
pages:
image: hosttoday/ht-docker-node:npmci
stage: pages
script:
- npmci command yarn global add npmpage
- npmci command npmpage
tags:
- docker
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -1,6 +1,6 @@
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
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,61 +0,0 @@
# gulp-function
accepts call to execute in gulp pipeline.
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/gulp-function)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/gulp-function)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/gulp-function)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/gulp-function/)
## Status for master
[![build status](https://gitlab.com/pushrocks/gulp-function/badges/master/build.svg)](https://gitlab.com/pushrocks/gulp-function/commits/master)
[![coverage report](https://gitlab.com/pushrocks/gulp-function/badges/master/coverage.svg)](https://gitlab.com/pushrocks/gulp-function/commits/master)
[![Dependency Status](https://david-dm.org/pushrocks/gulp-function.svg)](https://david-dm.org/pushrocks/gulp-function)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/gulp-function/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/gulp-function/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/gulp-function/badges/code.svg)](https://www.bithound.io/github/pushrocks/gulp-function)
[![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
```javascript
import * as gulp from 'gulp';
import gulpFunction from 'gulp-function' // default ES6 export
// import {forFirst, forEach, atEnd} from 'gulp-function'
let Q = require("q");
let myFunction = function (file, enc) { // file and enc are optional in case you want to modify the file object
let done = Q.defer();
console.log("Hello World!")
// NOTE:
// you can use done.resolve as callback function
// of any async tasks within this function
done.resolve();
return done.promise;
}
gulp.task('gulpTest',function() {
let stream = gulp.src('./mydir/*.something')
.pipe(gulpFunction(myFunction,'forEach')) //read the notes below
// .pipe(forEach(myFunction)) // if imported as >> import { forEach } from 'gulp-function' <<
.pipe(gulp.dest("./build/"));
return stream; // by returning the stream gulp knows when our task has finished.
});
```
### Notes:
* The first argument of gulpFunction can also be an **array of multiple functionnames**.
Each function can return a promise. The pipe stop will finish when every promise is fullfilled.
When providing an array of functions be careful with modifying the file object -> race condition
* The second argument can be empty, it defaults to "forEach"
* The following options are available:
* "forFirst" - executes when first chunk/vinylfile of the stream reaches the pipestop.
file is pushed further down the line when function's returned promise is fullfilled.
* "forEach" - executes like "forFirst" but with every chunk/vinylfile in the stream;
* "atEnd" - executes after all chunks have passed and are processed in full.
That means the stream's "finish" event fires **before "atLast" is executed**!!!
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

12
dist/index.d.ts vendored
View File

@ -1,12 +0,0 @@
/// <reference types="node" />
import 'typings-global';
import { Transform } from 'stream';
export declare type TExecutionMode = 'forEach' | 'forFirst' | 'atEnd';
export interface IPromiseFunction {
(file?: any, enc?: any): PromiseLike<any>;
}
declare let defaultExport: (functionsToExecuteArg: IPromiseFunction | IPromiseFunction[], executionModeArg?: TExecutionMode) => Transform;
export declare let forEach: (funcArg: IPromiseFunction) => Transform;
export declare let forFirst: (funcArg: IPromiseFunction) => Transform;
export declare let atEnd: (funcArg: IPromiseFunction) => Transform;
export default defaultExport;

76
dist/index.js vendored
View File

@ -1,76 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global");
const through2 = require("through2");
let defaultExport = (functionsToExecuteArg, executionModeArg = 'forEach') => {
let promiseArray = [];
let runFunction = function (functionArg, file, enc) {
let returnValue = functionArg(file, enc);
if (typeof returnValue !== 'undefined' && typeof returnValue.then !== 'undefined') {
promiseArray.push(returnValue);
}
};
let checkAndRunFunction = function (file, enc) {
if (typeof functionsToExecuteArg === 'function') {
runFunction(functionsToExecuteArg, file, enc);
}
else if (Array.isArray(functionsToExecuteArg)) {
for (let anyFunction in functionsToExecuteArg) {
runFunction(functionsToExecuteArg[anyFunction], file, enc);
}
}
else {
throw new Error('gulp-callfunction: something is strange with the given arguments');
}
return Promise.all(promiseArray);
};
let hasExecutedOnce = false;
let forEach = function (file, enc, cb) {
switch (executionModeArg) {
case 'forEach':
checkAndRunFunction(file, enc).then(function () {
cb(null, file);
});
break;
case 'forFirst':
if (hasExecutedOnce) {
checkAndRunFunction(file, enc)
.then(function () {
cb(null, file);
});
}
else {
cb(null, file);
}
hasExecutedOnce = true;
break;
case 'atEnd':
cb(null, file);
break;
default:
break;
}
};
let atEnd = function (cb) {
if (executionModeArg === 'atEnd') {
checkAndRunFunction(null, null).then(function () {
cb();
});
}
else {
cb();
}
};
return through2.obj(forEach, atEnd);
};
exports.forEach = (funcArg) => {
return defaultExport(funcArg, 'forEach');
};
exports.forFirst = (funcArg) => {
return defaultExport(funcArg, 'forFirst');
};
exports.atEnd = (funcArg) => {
return defaultExport(funcArg, 'atEnd');
};
exports.default = defaultExport;
//# sourceM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FhLENBQUEifQ==

View File

@ -3,8 +3,32 @@
"mode": "default"
},
"npmci": {
"globalNpmTools": [
"npmts"
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "gulp-function",
"description": "A Gulp plugin to execute functions within a Gulp task pipeline.",
"npmPackagename": "@push.rocks/gulp-function",
"license": "MIT",
"keywords": [
"gulp",
"plugin",
"task automation",
"stream manipulation",
"async function execution",
"pipeline",
"build tool",
"JavaScript",
"TypeScript"
]
}
},
"tsdoc": {
"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"
}
}

View File

@ -1,39 +1,63 @@
{
"name": "gulp-function",
"version": "2.2.5",
"description": "accepts a function call as parameter to execute in gulp pipeline",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"name": "@push.rocks/gulp-function",
"private": false,
"version": "3.0.7",
"description": "A Gulp plugin to execute functions within a Gulp task pipeline.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"scripts": {
"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)",
"startdev": "(git checkout master && git pull origin master)"
"test": "(tstest test/)",
"build": "(tsbuild --allowimplicitany)",
"buildDocs": "tsdoc"
},
"repository": {
"type": "git",
"url": "https://gitlab.com/pushrocks/gulp-function.git"
"url": "https://code.foss.global/push.rocks/gulp-function.git"
},
"keywords": [
"gulpplugin",
"gulp",
"function"
"plugin",
"task automation",
"stream manipulation",
"async function execution",
"pipeline",
"build tool",
"JavaScript",
"TypeScript"
],
"author": "Lossless GmbH <office@lossless.com> (https://lossless.com)",
"license": "MIT",
"bugs": {
"url": "https://gitlab.com/pushrocks/gulp-function/issues"
"url": "https://gitlab.com/push.rocks/gulp-function/issues"
},
"homepage": "https://gitlab.com/pushrocks/gulp-function",
"homepage": "https://code.foss.global/push.rocks/gulp-function",
"dependencies": {
"@push.rocks/smartpromise": "^4.0.3",
"@types/through2": "^2.0.32",
"smartq": "^1.1.1",
"through2": "^2.0.3",
"typings-global": "^1.0.16"
"through2": "^3.0.1"
},
"devDependencies": {
"beautylog": "^6.1.10",
"gulp": "^3.9.1",
"tapbundle": "^1.0.10"
}
"@git.zone/tsbuild": "^2.1.17",
"@git.zone/tsrun": "^1.2.46",
"@git.zone/tstest": "^1.0.28",
"@push.rocks/smartgulp": "^3.0.3",
"@push.rocks/tapbundle": "^5.0.15",
"gulp": "^4.0.2"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"type": "module",
"browserslist": [
"last 1 chrome versions"
]
}

7617
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

106
readme.md Normal file
View File

@ -0,0 +1,106 @@
# @push.rocks/gulp-function
[@push.rocks/gulp-function](https://www.npmjs.com/package/@push.rocks/gulp-function) is a Gulp plugin designed to execute custom functions within a Gulp pipeline. It accepts a function call as a parameter and allows for flexible task executions, including asynchronous tasks, with easy integration into the Gulp workflow.
## Install
To use @push.rocks/gulp-function in your project, you'll first need to install it via npm. You can do this by running the following command in your project's root directory:
```bash
npm install @push.rocks/gulp-function --save-dev
```
This command will add `@push.rocks/gulp-function` as a development dependency to your project, making it available for use in your Gulp tasks.
## Usage
The primary use case for `@push.rocks/gulp-function` is to incorporate custom function executions into your Gulp pipelines. This can be particularly useful for tasks that require conditional processing, external API calls, or any other logic that extends beyond the capabilities of existing Gulp plugins.
Here's how you can use `@push.rocks/gulp-function` within your Gulp setup:
### Basic Example
Let's start with a simple scenario where you want to log the path of files processed by Gulp.
```typescript
import gulp from 'gulp';
import gulpFunction, { forEach } from '@push.rocks/gulp-function';
const logFilePath = async (file: Buffer, enc: string) => {
console.log(`Processing file: ${file.path}`);
};
gulp.task('log', () => {
return gulp.src('./src/**/*.ts')
.pipe(forEach(logFilePath))
.pipe(gulp.dest('./dist'));
});
```
In this example, we're using the `forEach` method exported by `@push.rocks/gulp-function` to execute `logFilePath` for each file matched by `gulp.src`. The file's path is logged to the console during the build process.
### Advanced Use Case: Asynchronous Function Execution
`@push.rocks/gulp-function` truly shines when you need to perform asynchronous operations within your Gulp tasks. Here's an example that demonstrates making an asynchronous API call for each file:
```typescript
import gulp from 'gulp';
import gulpFunction, { forEach } from '@push.rocks/gulp-function';
import axios from 'axios';
const uploadFileToServer = async (file: Buffer, enc: string) => {
const formData = new FormData();
formData.append('file', file.contents, file.relative);
await axios.post('https://example.com/upload', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
});
console.log(`Uploaded file: ${file.path}`);
};
gulp.task('uploadFiles', () => {
return gulp.src('./uploads/**/*')
.pipe(forEach(uploadFileToServer))
.pipe(gulp.dest('./dist/uploads'));
});
```
In this more advanced example, we use the `forEach` method to upload each file to a remote server using `axios`. The function `uploadFileToServer` is executed for each file, where an HTTP POST request is made to upload the file. This shows how you can integrate asynchronous operations seamlessly into your Gulp pipeline.
### Execution Modes
`@push.rocks/gulp-function` supports three execution modes for your functions: `forEach`, `forFirst`, and `atEnd`.
- **forEach**: Executes the provided function for each file in the stream.
- **forFirst**: Executes the provided function only for the first file that passes through the stream.
- **atEnd**: Executes the provided function once after all files have passed through the stream.
These modes provide flexibility in determining when your custom functions should be triggered during the build process.
### Conclusion
`@push.rocks/gulp-function` is a powerful tool for integrating custom processing logic into Gulp workflows. Whether you need to execute simple synchronous tasks or complex asynchronous operations, `@push.rocks/gulp-function` offers the flexibility and ease of use to enhance your Gulp builds significantly.
Remember, the examples provided are starting points. The real power of `@push.rocks/gulp-function` lies in its ability to adapt to your specific use cases, enabling you to automate and streamline your build processes as never before.
## License and Legal Information
This 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.
**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.
### Trademarks
This 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.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By 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.

View File

@ -1,34 +1,35 @@
import { expect, tap } from 'tapbundle'
import { expect, tap } from '@push.rocks/tapbundle';
let gulp = require('gulp')
import * as gulpFunction from '../dist/index'
import * as smartgulp from '@push.rocks/smartgulp';
import gulp from 'gulp';
import * as gulpFunction from '../ts/index.js';
import * as beautylog from 'beautylog'
let smartq = require('smartq')
import * as smartpromise from '@push.rocks/smartpromise';
tap.test('should run through smoothly with ' + "'forEach'", async (tools) => {
let done = smartq.defer()
let counter = 0
gulp.src('./test/*.md')
.pipe(gulpFunction.forEach(async () => {
counter++
tap.test('should run through smoothly with ' + "'forEach'", async tools => {
let done = smartpromise.defer();
let counter = 0;
gulp.src('./test/testfiles/*.md').pipe(
gulpFunction.forEach(async () => {
counter++;
if (counter === 2) {
done.resolve()
done.resolve();
}
}))
await done.promise
})
})
);
await done.promise;
});
tap.test('should run through smoothly with ' + "'forEach'", async (tools) => {
let done = smartq.defer()
let counter = 0
gulp.src('./test/*.md')
.pipe(gulpFunction.atEnd(async () => {
console.log('atEnd')
done.resolve()
}))
await done.promise
})
tap.test('should run through smoothly with ' + "'forEach'", async tools => {
let done = smartpromise.defer();
let counter = 0;
smartgulp.src(['./test/testfiles/*.md']).pipe(
gulpFunction.atEnd(async () => {
console.log('atEnd');
done.resolve();
})
);
await done.promise;
});
tap.start()
tap.start();

View File

@ -1,2 +0,0 @@
# Test.md
This is a test file for the test.js gulp pipeline

View File

@ -1,2 +0,0 @@
# Test.md
This is another test file for the test.js gulp pipeline

1
test/testfiles/test01.md Normal file
View File

@ -0,0 +1 @@
# the 1st testfile

1
test/testfiles/test02.md Normal file
View File

@ -0,0 +1 @@
# the second testfile

1
test/testfiles/test03.md Normal file
View File

@ -0,0 +1 @@
# the third testfile

1
test/testfiles/test04.md Normal file
View File

@ -0,0 +1 @@
# the fourth testfile

1
test/testfiles/test05.md Normal file
View File

@ -0,0 +1 @@
# the fifth testfile

1
test/testfiles/test06.md Normal file
View File

@ -0,0 +1 @@
# the sixth testfile

1
test/testfiles/test07.md Normal file
View File

@ -0,0 +1 @@
# the seventh testfile

1
test/testfiles/test08.md Normal file
View File

@ -0,0 +1 @@
# the eighth testfile

1
test/testfiles/test09.md Normal file
View File

@ -0,0 +1 @@
# the nineth testfile

1
test/testfiles/test10.md Normal file
View File

@ -0,0 +1 @@
# the tenth testfile

1
test/testfiles/test11.md Normal file
View File

@ -0,0 +1 @@
# the eleventh testfile

1
test/testfiles/test12.md Normal file
View File

@ -0,0 +1 @@
# the twelveth testfile

1
test/testfiles/test13.md Normal file
View File

@ -0,0 +1 @@
# the second testfile

1
test/testfiles/test14.md Normal file
View File

@ -0,0 +1 @@
# the second testfile

1
test/testfiles/test15.md Normal file
View File

@ -0,0 +1 @@
# the second testfile

1
test/testfiles/test16.md Normal file
View File

@ -0,0 +1 @@
# the second testfile

1
test/testfiles/test17.md Normal file
View File

@ -0,0 +1 @@
# the second testfile

1
test/testfiles/test18.md Normal file
View File

@ -0,0 +1 @@
# the 18th testfile

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/gulp-function',
version: '3.0.7',
description: 'accepts a function call as parameter to execute in gulp pipeline'
}

View File

@ -1,89 +1,87 @@
import 'typings-global'
import * as q from 'smartq'
import * as through2 from 'through2'
import { Transform } from 'stream'
import * as smartpromise from '@push.rocks/smartpromise';
import * as through2 from 'through2';
import { Transform } from 'stream';
export type TExecutionMode = 'forEach' | 'forFirst' | 'atEnd'
export type TExecutionMode = 'forEach' | 'forFirst' | 'atEnd';
export interface IPromiseFunction {
(file?, enc?): PromiseLike<any>
(file?, enc?): PromiseLike<any>;
}
let defaultExport = (
functionsToExecuteArg: IPromiseFunction | IPromiseFunction[],
executionModeArg: TExecutionMode = 'forEach'
): Transform => {
let promiseArray = []
let runFunction = function (functionArg, file, enc) {
let returnValue = functionArg(file, enc)
let promiseArray = [];
let runFunction = function(functionArg, file, enc) {
let returnValue = functionArg(file, enc);
if (typeof returnValue !== 'undefined' && typeof returnValue.then !== 'undefined') {
promiseArray.push(returnValue)
}
promiseArray.push(returnValue);
}
};
let checkAndRunFunction = function (file, enc) {
let checkAndRunFunction = function(file, enc) {
if (typeof functionsToExecuteArg === 'function') {
runFunction(functionsToExecuteArg, file, enc)
runFunction(functionsToExecuteArg, file, enc);
} else if (Array.isArray(functionsToExecuteArg)) {
for (let anyFunction in functionsToExecuteArg) {
runFunction(functionsToExecuteArg[ anyFunction ], file, enc)
runFunction(functionsToExecuteArg[anyFunction], file, enc);
}
} else {
throw new Error('gulp-callfunction: something is strange with the given arguments')
}
return Promise.all(promiseArray)
throw new Error('gulp-callfunction: something is strange with the given arguments');
}
return Promise.all(promiseArray);
};
let hasExecutedOnce = false
let forEach = function (file, enc, cb) { // the forEach function is called for every chunk
let hasExecutedOnce = false;
let forEach = function(file, enc, cb) {
// the forEach function is called for every chunk
switch (executionModeArg) {
case 'forEach':
checkAndRunFunction(file, enc).then(function () {
cb(null, file)
})
break
checkAndRunFunction(file, enc).then(function() {
cb(null, file);
});
break;
case 'forFirst':
if (hasExecutedOnce) {
checkAndRunFunction(file, enc)
.then(function () {
cb(null, file)
})
checkAndRunFunction(file, enc).then(function() {
cb(null, file);
});
} else {
cb(null, file)
cb(null, file);
}
hasExecutedOnce = true
break
hasExecutedOnce = true;
break;
case 'atEnd':
cb(null, file)
break
cb();
break;
default:
break
}
break;
}
};
let atEnd = function (cb) {
let atEnd = function(cb) {
if (executionModeArg === 'atEnd') {
checkAndRunFunction(null, null).then(function () {
cb()
})
checkAndRunFunction(null, null).then(function() {
cb();
});
} else {
cb()
cb();
}
}
return through2.obj(forEach, atEnd)
}
};
return through2.obj(forEach, atEnd);
};
export let forEach = (funcArg: IPromiseFunction) => {
return defaultExport(funcArg, 'forEach')
}
return defaultExport(funcArg, 'forEach');
};
export let forFirst = (funcArg: IPromiseFunction) => {
return defaultExport(funcArg, 'forFirst')
}
return defaultExport(funcArg, 'forFirst');
};
export let atEnd = (funcArg: IPromiseFunction) => {
return defaultExport(funcArg, 'atEnd')
}
return defaultExport(funcArg, 'atEnd');
};
export default defaultExport
export default defaultExport;

14
tsconfig.json Normal file
View File

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

View File

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

1284
yarn.lock

File diff suppressed because it is too large Load Diff