Compare commits
82 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f5371007f1 | |||
| 60607ce021 | |||
| edcb1d114f | |||
| 3ba5685914 | |||
| cb0f810201 | |||
| 94a5d3022e | |||
| 919fcfd9f5 | |||
| 660ffd8880 | |||
| 1744e9b338 | |||
| b738a360cc | |||
| 0c703cb5c3 | |||
| 27ee7a532a | |||
| 29d439ce0d | |||
| faa4bb88a8 | |||
| a95319d99f | |||
| e7c0e1228b | |||
| 9586f34d64 | |||
| 6300845ec8 | |||
| 2316a983ed | |||
| a1fa6b751e | |||
| 5792a13b01 | |||
| 1008c3f103 | |||
| c366bde211 | |||
| e22c6764b7 | |||
| 50836eab06 | |||
| 077834f7a4 | |||
| ca348b5475 | |||
| 2c9ab52cee | |||
| 7d35f4c90b | |||
| a05253bdcd | |||
| 54b80098d2 | |||
| c39a4a6cb0 | |||
| f325479a11 | |||
| c79f443c18 | |||
| 14bb4a90bb | |||
| 98a583bae1 | |||
| 848d9ac1e0 | |||
| e7ccd9aec4 | |||
| 63bf7204dd | |||
| a34a1b89fe | |||
| f4455a9b91 | |||
| 1a01198d7f | |||
| b3ec364a1d | |||
| 5d15c96511 | |||
| f6e071156b | |||
| 63fe7c7423 | |||
| c8dcdc0df4 | |||
| 743c7a03a5 | |||
| f9e7bf450b | |||
| b55a511fcb | |||
| 96c15cb90a | |||
| 0d772e8ab0 | |||
| a324deb942 | |||
| cb60bec110 | |||
| 291583b17a | |||
| 9d54da207f | |||
| 7aad993847 | |||
| c208f04e23 | |||
| 54d8ef2576 | |||
| 8b891c74e4 | |||
| 1d8de68a66 | |||
| a2b37a066d | |||
| 8a2c516274 | |||
| e10c31c740 | |||
| af68a92702 | |||
| a8c3fa048a | |||
| bea33fa29f | |||
| 739542bda1 | |||
| 63cf7091a1 | |||
| 04d7f9cf7e | |||
| afc9fd122f | |||
| a3dec7bb8a | |||
| 0e725c3fb4 | |||
| 6cd0ee78a3 | |||
| b037dc99df | |||
| 27439d84cd | |||
| ada13619d0 | |||
| 9ae1a40260 | |||
| e19184e29b | |||
| 36e02502d0 | |||
| 75219a5474 | |||
| 8f0ecb3f4a |
@@ -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
|
||||
@@ -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
|
||||
+17
-8
@@ -1,11 +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
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"@ship.zone/szci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmRegistryUrl": "registry.npmjs.org"
|
||||
},
|
||||
"@git.zone/cli": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "gulp-function",
|
||||
"shortDescription": "Function execution for Gulp streams",
|
||||
"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"
|
||||
]
|
||||
},
|
||||
"release": {
|
||||
"registries": [
|
||||
"https://verdaccio.lossless.digital",
|
||||
"https://registry.npmjs.org"
|
||||
],
|
||||
"accessLevel": "public"
|
||||
}
|
||||
},
|
||||
"@git.zone/tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.\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 or third parties, and are not included within the scope of the MIT license granted herein.\n\nUse of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District Court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or 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"
|
||||
}
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 4.2.4
|
||||
deploy:
|
||||
provider: npm
|
||||
email: npm@lossless.digital
|
||||
api_key:
|
||||
secure: TWN/oiICeNbAhGTbwf75FnKhXnIvyA66FhNF7C0jpjn2SChSgTANai87r0f9oU9ZP3307XdGHB+fTTCJnk3upNiBoWZnkV8skkAlseOY4mVzF9mS0ZEkxVR32FjJDWfqzv6hC+Y9qNDsGs2+Avsm6fQUOispLXYAk6VzSQC1HgIfyOJtIWT5LqEyXyT6oJIZ7xwt1CYcIeEpHUiAaPYsMEpwF5OBDFByVmNV38VdRGIBsoQd3lixso7/zOOgYvjR4b/onz5WzeWYlhzAuyzOnRGr1r/9eXAzzkYydvgFx3ix5OlrreKVFB6OtMpz4jmHdu9YDGT5bcvL2bSU2SGVQM5Bx8zZXkAxACQR8ZvWmPaWYAWCu9wrW5oovjqFUV0iR26z/sTABJqz4GaXf/vFcll2EdTfUT6xj2kCodfxljaudjPUF27FSt1UJBC7jQky08wHb6+onrE8WoQXteIE2oxtHWEGOlV/GAz0+q4ih0bdOSKfThmux0iEFmeF16sWH9UdL2jBBKuus+fBPdhA3V6uwYQtsCAurhquQLISkf7kT3KujdLS302bEbkut+D1Kd22IYA1J0wYd87th88TZHx7wgQyC+8lVHG+B1R20xGLxyHVEOfyZtChfBRdn53EcUiA2XriJbfiIym4dAMUtOg2iRJamHAL7jebQEUu7oA=
|
||||
on:
|
||||
tags: true
|
||||
repo: pushrocks/gulp-function
|
||||
notifications:
|
||||
slack:
|
||||
secure: Bb8P3fboL52CugSsp0RhOkGCeWVbgjb+QDpnMHdSOa0Nequj8V4kvrzBLZOBOjaSB0/gMvdoB4Slv2bls1dAxXW1IX1DdRb3RLMKj/Owje7eTd4IoUuSs49y6/yEkVK+E1wicdwjlMmvsk8fQE/owDRMRXYoXxhN2ZOVSQvAQ3iBO0eokFvWO7yj/VSxKoITymCXA3LfyzXXUuhvxuQd3BPZCe25xa6GWuHtaa5fbJg17pp8jJX6VZYLSRcSYyJxMU8SLdkrOsQZKj0+/Yfpu7XTmPbqxjNapuE7Zm70mi+aB26IQCnmwkdcEQNJVxQOKoP2+/ZnDfcTLQROwH1PJVzol0hneH6DdOlWt9bvBJcUvFRwaDgIb5xXQV8bGsRe5ayE/4MgCgfvdBTvevu6n12fmPx74prIv4pOPMwlALjjP8XavGL4A6amOuV7fJiSyGAku8aUe1rlUXyfoHJswMyOfkIsvnGDE3eEfq1WUIjn8tW1ZozJyoCTAIh6IHPI3Nsg3LkTRvDHPYq25/xCKWxGb2OaJc3JeqVREqm0auDqj6HoVAi/mW/uyvwX9jEVX8fNoQ69ac5VUMFfn2Mx3sU6aHKgZe/tdrtql6NYtIA+g5/ZDnHE1mnbl6MfrYiKwRbrICH5v/u1xK+4+yh09BUqazi3PzOhyTRfba/gRUg=
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
Vendored
+26
@@ -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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
# gulp-function
|
||||
accepts call to execute in gulp pipeline.
|
||||
|
||||
### Status
|
||||
[](https://travis-ci.org/pushrocks/gulp-function)
|
||||
[](https://david-dm.org/pushrocks/gulp-function)
|
||||
[](https://www.bithound.io/github/pushrocks/gulp-function/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/gulp-function)
|
||||
[](https://codecov.io/github/pushrocks/gulp-function?branch=master)
|
||||
|
||||
### Version
|
||||
[](https://badge.fury.io/gh/pushrocks%2Fgulp-function)
|
||||
[](https://badge.fury.io/js/gulp-function)
|
||||
|
||||
### Usage
|
||||
```javascript
|
||||
var gulp = require("gulp");
|
||||
var gulpFunction = require("gulp-function");
|
||||
var Q = require("q");
|
||||
|
||||
var myFunction = function () {
|
||||
var 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() {
|
||||
var stream = gulp.src('./mydir/*.something')
|
||||
.pipe(gulpFunction(myFunction,'forEach')) //read the notes below
|
||||
.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.
|
||||
* 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**!!!
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
# Changelog
|
||||
|
||||
## 2026-05-02 - 3.0.8 - fix(gulp-function)
|
||||
correct forFirst execution behavior, improve async error handling, and modernize package metadata
|
||||
|
||||
- fixes `forFirst` so the callback runs only for the first file instead of every file after the first
|
||||
- normalizes thrown values into `Error` instances and propagates async failures through the Gulp stream
|
||||
- adds stronger TypeScript typings, updates tests, and refreshes package/configuration metadata for the current toolchain
|
||||
|
||||
## 2024-03-10 - 3.0.7 - maintenance
|
||||
Release 3.0.7 with repository and configuration maintenance updates.
|
||||
|
||||
- Updated package metadata and description
|
||||
- Updated TypeScript configuration
|
||||
- Updated npm host configuration
|
||||
|
||||
## 2024-03-10 - 3.0.6 - core
|
||||
Applied a core update fix.
|
||||
|
||||
- fix(core): update
|
||||
|
||||
## 2023-06-30 - 3.0.5 - maintenance
|
||||
Released 3.0.5 with a core fix and organization migration updates.
|
||||
|
||||
- fix(core): update
|
||||
- Switched to the new organization scheme
|
||||
|
||||
## 2020-01-18 - 3.0.4 - core
|
||||
Applied a core update fix.
|
||||
|
||||
- fix(core): update
|
||||
|
||||
## 2020-01-18 - 3.0.3 - core
|
||||
Applied a core update fix.
|
||||
|
||||
- fix(core): update
|
||||
|
||||
## 2020-01-18 - 3.0.2 - core
|
||||
Applied a core update fix.
|
||||
|
||||
- fix(core): update
|
||||
|
||||
## 2018-12-09 - 3.0.1 - core
|
||||
Applied a core update fix.
|
||||
|
||||
- fix(core): update
|
||||
|
||||
## 2018-12-09 - 3.0.0 - npm
|
||||
Updated npm package permissions.
|
||||
|
||||
- fix(npm): permissions
|
||||
|
||||
## 2018-12-09 - 2.2.16 - npm scope
|
||||
Introduced a breaking npm scope change.
|
||||
|
||||
- BREAKING CHANGE(npm scope): update
|
||||
|
||||
## 2018-12-09 - 2.2.15 - license
|
||||
Updated licensing metadata.
|
||||
|
||||
- Switched from brand name to company name in license information
|
||||
|
||||
## 2018-01-29 - 2.2.14 - core
|
||||
Released 2.2.14 with standards updates and documentation fixes.
|
||||
|
||||
- Updated core to latest gitzone standards
|
||||
- Fixed sample code in README
|
||||
|
||||
## 2017-04-30 - 2.2.13 to 2.2.11 - maintenance
|
||||
Rolled up minor maintenance and documentation updates across these releases.
|
||||
|
||||
- Updated CI configuration
|
||||
- Updated README
|
||||
- Updated project standards
|
||||
|
||||
## 2017-04-30 - 2.2.10 to 2.2.6 - mixed
|
||||
Delivered a mix of dependency, documentation, and behavior improvements.
|
||||
|
||||
- Updated dependencies
|
||||
- Updated docs, README, and .gitignore
|
||||
- Fixed pipe cleanup behavior
|
||||
|
||||
## 2016-11-25 - 2.2.5 to 2.2.1 - core
|
||||
Shipped iterative fixes and API improvements in the 2.2.x line.
|
||||
|
||||
- Fixed `.forEach` return behavior
|
||||
- Added `.forEach`, `.atEnd`, and `.forFirst`
|
||||
- Switched to ES6 default import
|
||||
- Included testing and documentation improvements as part of the release series
|
||||
|
||||
## 2016-10-18 - 2.0.0 - ci
|
||||
Updated CI base image for the 2.0.0 release.
|
||||
|
||||
- Fixed base image for CI
|
||||
|
||||
## 2016-06-11 - 1.3.6 - core
|
||||
Added support for modifying the file object.
|
||||
|
||||
- Added possibility to modify the file object
|
||||
|
||||
## 2016-06-03 - 1.3.5 to 1.3.1 - maintenance
|
||||
Bundled dependency, CI, and documentation maintenance updates.
|
||||
|
||||
- Updated GitLab CI configuration
|
||||
- Switched to npmts-g
|
||||
- Updated README and removed Travis
|
||||
- Fixed a missing dependency
|
||||
- Added GitLab CI
|
||||
- Updated dependencies
|
||||
|
||||
## 2016-04-07 - 1.3.0 - dependencies
|
||||
Adjusted development dependencies.
|
||||
|
||||
- Added beautylog back as a dev dependency
|
||||
|
||||
## 2016-04-04 - 1.2.5 to 1.2.1 - maintenance
|
||||
Bundled package, dependency, and README fixes across patch releases.
|
||||
|
||||
- Fixed package.json
|
||||
- Updated dependencies
|
||||
- Fixed README issues
|
||||
|
||||
## 2016-03-26 - 1.2.0 - core
|
||||
Delivered functional fixes and dependency cleanup.
|
||||
|
||||
- Fixed issue #3
|
||||
- Removed beautylog dependency
|
||||
- Updated dependencies and coverage badge configuration
|
||||
|
||||
## 2016-02-14 - 1.1.1 - core
|
||||
Added new callback handling functionality.
|
||||
|
||||
- Added `forFirst`
|
||||
- Included badge and README updates in this release cycle
|
||||
|
||||
## 2016-02-14 - 1.1.0 - dependencies
|
||||
Updated promise handling dependency.
|
||||
|
||||
- Updated promise
|
||||
|
||||
## 2016-02-12 - 1.0.4 - core
|
||||
Improved async function handling.
|
||||
|
||||
- Now accepts promises as return values of supplied functions
|
||||
- Included README updates
|
||||
|
||||
## 2016-02-12 - 1.0.3 - configuration
|
||||
Added npmts configuration.
|
||||
|
||||
- Added `npmts.json`
|
||||
|
||||
## 2016-02-02 - 1.0.2 - tests
|
||||
Improved test coverage.
|
||||
|
||||
- Added better tests and coverage
|
||||
|
||||
## 2016-02-01 - 1.0.1 to 1.0.0 - maintenance
|
||||
Initial stable release cycle with tooling and dependency updates.
|
||||
|
||||
- Updated dependencies
|
||||
- Updated Travis configuration
|
||||
- Updated npmts
|
||||
|
||||
## 2015-11-30 - 0.0.12 to 0.0.8 - maintenance
|
||||
Early project setup and package maintenance updates.
|
||||
|
||||
- Updated keywords and package metadata
|
||||
- Cleaned up project structure
|
||||
- Updated dependencies
|
||||
|
||||
## 2015-10-26 - 0.0.7 - core
|
||||
Added callback support to `atEnd`.
|
||||
|
||||
- Added callback to `function() atEnd`
|
||||
- Included badge updates
|
||||
|
||||
## 2015-10-26 - 0.0.6 to 0.0.4 - tooling
|
||||
Established release automation and tooling.
|
||||
|
||||
- Added automatic version release through Travis for npm
|
||||
|
||||
## 2015-10-25 - 0.0.3 - tests
|
||||
Improved early project quality and stability.
|
||||
|
||||
- Added tests
|
||||
- Included a small fix
|
||||
|
||||
## 2015-09-17 - 0.0.2 - core
|
||||
Made the package functional and added initial project files.
|
||||
|
||||
- Now working
|
||||
- Added `.gitignore`
|
||||
- Added README
|
||||
|
||||
## 2015-09-04 - 0.0.1 - release
|
||||
Initial package publication and CI setup.
|
||||
|
||||
- Published npm package
|
||||
- Added Travis CI
|
||||
Vendored
-6
@@ -1,6 +0,0 @@
|
||||
/// <reference path="typings/main.d.ts" />
|
||||
"use strict";
|
||||
exports.Q = require("q");
|
||||
exports.through2 = require("through2");
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImd1bHBmdW5jdGlvbi5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDBDQUEwQzs7QUFFL0IsU0FBQyxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNqQixnQkFBUSxHQUFHLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQyIsImZpbGUiOiJndWxwZnVuY3Rpb24ucGx1Z2lucy5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCJ0eXBpbmdzL21haW4uZC50c1wiIC8+XG5cbmV4cG9ydCBsZXQgUSA9IHJlcXVpcmUoXCJxXCIpO1xuZXhwb3J0IGxldCB0aHJvdWdoMiA9IHJlcXVpcmUoXCJ0aHJvdWdoMlwiKTtcbiJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
||||
Vendored
-64
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Push.Rocks
|
||||
Copyright (c) 2022 Task Venture Capital GmbH <hello@task.vc>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"@ship.zone/szci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmRegistryUrl": "registry.npmjs.org"
|
||||
},
|
||||
"@git.zone/cli": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "gulp-function",
|
||||
"shortDescription": "Function execution for Gulp streams",
|
||||
"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"
|
||||
]
|
||||
},
|
||||
"release": {
|
||||
"registries": [
|
||||
"https://verdaccio.lossless.digital",
|
||||
"https://registry.npmjs.org"
|
||||
],
|
||||
"accessLevel": "public"
|
||||
}
|
||||
},
|
||||
"@git.zone/tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.\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 or third parties, and are not included within the scope of the MIT license granted herein.\n\nUse of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District Court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or 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"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"mode":"default",
|
||||
"coveralls":true
|
||||
}
|
||||
+55
-23
@@ -1,35 +1,67 @@
|
||||
{
|
||||
"name": "gulp-function",
|
||||
"version": "1.3.0",
|
||||
"description": "accepts a function call as parameter to execute in gulp pipeline",
|
||||
"main": "dist/index.js",
|
||||
"name": "@push.rocks/gulp-function",
|
||||
"version": "3.0.8",
|
||||
"private": false,
|
||||
"description": "A Gulp plugin to execute functions within a Gulp task pipeline.",
|
||||
"exports": {
|
||||
".": "./dist_ts/index.js"
|
||||
},
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"author": "Task Venture Capital GmbH <hello@task.vc>",
|
||||
"license": "MIT",
|
||||
"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",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"dependencies": {
|
||||
"through2": "^4.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^4.4.0",
|
||||
"@git.zone/tsdoc": "^2.0.3",
|
||||
"@git.zone/tstest": "^3.6.3",
|
||||
"@types/gulp": "^4.0.18",
|
||||
"@types/node": "^25.6.0",
|
||||
"@types/through2": "^2.0.41",
|
||||
"gulp": "^5.0.1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.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://github.com/pushrocks/gulp-function/issues"
|
||||
"url": "https://code.foss.global/push.rocks/gulp-function/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pushrocks/gulp-function",
|
||||
"dependencies": {
|
||||
"q": "^1.4.1",
|
||||
"through2": "^2.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.1",
|
||||
"npmts": "^5.0.3"
|
||||
}
|
||||
"homepage": "https://code.foss.global/push.rocks/gulp-function",
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
".smartconfig.json",
|
||||
"license",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
||||
Generated
+9129
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
# @push.rocks/gulp-function
|
||||
|
||||
`@push.rocks/gulp-function` is a tiny, typed Gulp plugin for running your own sync or async functions inside a Gulp object stream without changing the files that flow through it. Use it when a pipeline needs custom side effects: logging, validation, deployment calls, metrics, cache invalidation, or any project-specific action that does not deserve a full custom Gulp plugin.
|
||||
|
||||
## Issue Reporting and Security
|
||||
|
||||
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
pnpm add -D @push.rocks/gulp-function
|
||||
```
|
||||
|
||||
## What It Does
|
||||
|
||||
Gulp streams are great at moving Vinyl files through transforms. Sometimes you need to run code at a specific point in that stream while leaving every file untouched. `@push.rocks/gulp-function` gives you three small helpers for that:
|
||||
|
||||
- `forEach(fn)`: run `fn(file, enc)` for every file and pass the file on after the function resolves.
|
||||
- `forFirst(fn)`: run `fn(file, enc)` only for the first file and pass all files through.
|
||||
- `atEnd(fn)`: pass all files through immediately, then run `fn(null, null)` once when the stream flushes.
|
||||
|
||||
The default export exposes the same behavior as `gulpFunction(fnOrFns, mode)`, where `mode` is `'forEach'`, `'forFirst'`, or `'atEnd'`. The default export also accepts an array of functions and runs them in parallel for the selected mode.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```ts
|
||||
import gulp from 'gulp';
|
||||
import { forEach } from '@push.rocks/gulp-function';
|
||||
|
||||
interface IVinylFile {
|
||||
path: string;
|
||||
relative: string;
|
||||
}
|
||||
|
||||
export const logFiles = () =>
|
||||
gulp.src('./src/**/*.ts')
|
||||
.pipe(forEach<IVinylFile>(async (file) => {
|
||||
if (!file) return;
|
||||
console.log(`Processing ${file.relative}`);
|
||||
}))
|
||||
.pipe(gulp.dest('./dist'));
|
||||
```
|
||||
|
||||
The function can return a promise or a plain value. If it throws or rejects, the transform reports the error to Gulp and the pipeline fails normally.
|
||||
|
||||
## API
|
||||
|
||||
### `forEach(func)`
|
||||
|
||||
Runs `func(file, enc)` for every Vinyl file in the stream. The file is pushed onward only after `func` has completed.
|
||||
|
||||
```ts
|
||||
import { forEach } from '@push.rocks/gulp-function';
|
||||
|
||||
gulp.src('./content/**/*.md')
|
||||
.pipe(forEach(async (file) => {
|
||||
console.log(file?.relative);
|
||||
}))
|
||||
.pipe(gulp.dest('./public'));
|
||||
```
|
||||
|
||||
### `forFirst(func)`
|
||||
|
||||
Runs `func(file, enc)` only for the first file. This is useful for one-time setup that should still be triggered by a stream.
|
||||
|
||||
```ts
|
||||
import { forFirst } from '@push.rocks/gulp-function';
|
||||
|
||||
gulp.src('./assets/**/*')
|
||||
.pipe(forFirst(async (file) => {
|
||||
console.log(`Starting asset pipeline with ${file?.relative}`);
|
||||
}))
|
||||
.pipe(gulp.dest('./dist/assets'));
|
||||
```
|
||||
|
||||
### `atEnd(func)`
|
||||
|
||||
Runs `func(null, null)` once after all files have passed through. This is ideal for final notifications, summary output, or flushing external state.
|
||||
|
||||
```ts
|
||||
import { atEnd, forEach } from '@push.rocks/gulp-function';
|
||||
|
||||
let fileCount = 0;
|
||||
|
||||
gulp.src('./src/**/*')
|
||||
.pipe(forEach(() => {
|
||||
fileCount++;
|
||||
}))
|
||||
.pipe(atEnd(async () => {
|
||||
console.log(`Handled ${fileCount} files`);
|
||||
}))
|
||||
.pipe(gulp.dest('./dist'));
|
||||
```
|
||||
|
||||
### Default Export
|
||||
|
||||
```ts
|
||||
import gulpFunction from '@push.rocks/gulp-function';
|
||||
|
||||
gulp.src('./src/**/*')
|
||||
.pipe(gulpFunction([
|
||||
async (file) => console.log(file?.relative),
|
||||
async () => console.log('side effect complete')
|
||||
], 'forEach'));
|
||||
```
|
||||
|
||||
Supported TypeScript exports:
|
||||
|
||||
- `TExecutionMode`: `'forEach' | 'forFirst' | 'atEnd'`
|
||||
- `TGulpFunctionEncoding`: `BufferEncoding | string | null`
|
||||
- `TGulpFunctionResult`: `PromiseLike<unknown> | unknown`
|
||||
- `IPromiseFunction<TFile = unknown>`: `(file?: TFile | null, enc?: TGulpFunctionEncoding) => TGulpFunctionResult`
|
||||
|
||||
## Behavior Notes
|
||||
|
||||
- Files are passed through unchanged.
|
||||
- Async functions are awaited before the relevant transform or flush callback completes.
|
||||
- `forEach` and `forFirst` receive the current file and stream encoding.
|
||||
- `atEnd` receives `null` for both arguments because no single file is active during flush.
|
||||
- Arrays passed to the default export are executed with `Promise.all`.
|
||||
- Non-`Error` thrown values are normalized to `Error` instances before being passed to Gulp.
|
||||
|
||||
## Testing and Build
|
||||
|
||||
```bash
|
||||
pnpm test
|
||||
pnpm run build
|
||||
```
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
|
||||
|
||||
**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 or third parties, 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 or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Registered at District Court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or 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.
|
||||
-102
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC3B,IAAI,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC/C,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACrC,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;AAErB,IAAI,UAAU,GAAG;IACb,IAAI,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,CAAA;IACpB,SAAS,CAAC,GAA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B,CAAC,CAAC,CAAC;aACF,IAAI,CAAC,YAAY,CAAC,aAAa,EAAC,OAAO,CAAC,CAAC;aACzC,IAAI,CAAC,YAAY,CAAC,eAAe,EAAC,OAAO,CAAC,CAAC,CAAC;QAEjD,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAC;YACf,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAClC,IAAI,EAAE,CAAC;QACX,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
||||
@@ -0,0 +1,58 @@
|
||||
import { finished } from 'node:stream/promises';
|
||||
|
||||
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import gulp from 'gulp';
|
||||
import * as gulpFunction from '../ts/index.js';
|
||||
|
||||
interface ITestVinylFile {
|
||||
relative: string;
|
||||
}
|
||||
|
||||
tap.test('should run through smoothly with forEach', async () => {
|
||||
const processedFiles: string[] = [];
|
||||
const stream = gulp.src('./test/testfiles/*.md').pipe(
|
||||
gulpFunction.forEach<ITestVinylFile>(async (fileArg) => {
|
||||
if (fileArg) {
|
||||
processedFiles.push(fileArg.relative);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
stream.resume();
|
||||
await finished(stream);
|
||||
expect(processedFiles).toHaveLength(18);
|
||||
});
|
||||
|
||||
tap.test('should run only once with forFirst', async () => {
|
||||
const processedFiles: string[] = [];
|
||||
const stream = gulp.src('./test/testfiles/*.md').pipe(
|
||||
gulpFunction.forFirst<ITestVinylFile>(async (fileArg) => {
|
||||
if (fileArg) {
|
||||
processedFiles.push(fileArg.relative);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
stream.resume();
|
||||
await finished(stream);
|
||||
expect(processedFiles).toHaveLength(1);
|
||||
});
|
||||
|
||||
tap.test('should run once after all files with atEnd', async () => {
|
||||
let atEndCounter = 0;
|
||||
let passthroughCounter = 0;
|
||||
const stream = gulp.src('./test/testfiles/*.md').pipe(
|
||||
gulpFunction.atEnd(async () => {
|
||||
atEndCounter++;
|
||||
})
|
||||
);
|
||||
|
||||
stream.on('data', () => {
|
||||
passthroughCounter++;
|
||||
});
|
||||
await finished(stream);
|
||||
expect(atEndCounter).toEqual(1);
|
||||
expect(passthroughCounter).toEqual(18);
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
-118
@@ -1,118 +0,0 @@
|
||||
/// <reference path="../ts/typings/main.d.ts" />
|
||||
var gulp = require("gulp");
|
||||
var gulpFunction = require("../dist/index.js");
|
||||
var beautylog = require("beautylog");
|
||||
var Q = require("q");
|
||||
|
||||
var myFunction = function () {
|
||||
var done = Q.defer()
|
||||
beautylog.log("Function executed");
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
var myFunction2 = function () {
|
||||
var done = Q.defer();
|
||||
beautylog.ok("Function2 executed");
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
var myFunction3 = function () {
|
||||
var done = Q.defer();
|
||||
beautylog.success("Function3 executed");
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
var beforeFunction = function () {
|
||||
var done = Q.defer();
|
||||
beautylog.success("beforeFunction executed");
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
var middleFunctionRun = false;
|
||||
|
||||
var middleFunction = function () {
|
||||
var done = Q.defer();
|
||||
beautylog.success("middleFunction executed");
|
||||
setTimeout(function(){
|
||||
beautylog.log("timeout fired");
|
||||
middleFunctionRun = true;
|
||||
done.resolve();
|
||||
}, 500);
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
var afterFunction = function () {
|
||||
var done = Q.defer();
|
||||
beautylog.success("afterFunction executed");
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
let timeoutFunction = function(){
|
||||
var done = Q.defer();
|
||||
setTimeout(function(){
|
||||
beautylog.log("largeTimeout fired");
|
||||
done.resolve();
|
||||
},2000);
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
|
||||
|
||||
describe("gulpFunction",function(){
|
||||
it("should run through smoothly with " + "'forEach'".blue,function(done){
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction(myFunction,'forEach'))
|
||||
.pipe(gulp.dest("./test/result/"));
|
||||
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction([myFunction2,myFunction3],'forEach'))
|
||||
.pipe(gulp.dest("./test/result/"))
|
||||
.pipe(gulpFunction(done,"atEnd"));
|
||||
|
||||
});
|
||||
|
||||
it("should run through smoothly with " + "'atEnd'".blue,function(done){
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction(myFunction,'atEnd'))
|
||||
.pipe(gulp.dest("./test/result/"));
|
||||
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction([myFunction2,myFunction3],'atEnd'))
|
||||
.pipe(gulp.dest("./test/result/"))
|
||||
.pipe(gulpFunction(done,"atEnd"));
|
||||
});
|
||||
|
||||
it("should run through smoothly once with " + "'atFirst'".blue,function(done){
|
||||
|
||||
gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction([myFunction2,myFunction3],'forFirst'))
|
||||
.pipe(gulp.dest("./test/result/"))
|
||||
.pipe(gulpFunction(done,"atEnd"));
|
||||
});
|
||||
|
||||
it("should run in order",function(done){
|
||||
this.timeout(5000);
|
||||
let stream = gulp.src('./test/*.md')
|
||||
.pipe(gulpFunction([beforeFunction,middleFunction,middleFunction],'atEnd'))
|
||||
.pipe(gulpFunction(function(){
|
||||
beautylog.log("stream progressed");
|
||||
var done2 = Q.defer();
|
||||
done2.resolve();
|
||||
return done2.promise;
|
||||
},"forEach"))
|
||||
.pipe(gulpFunction(function(){
|
||||
beautylog.log("nextStep");
|
||||
}))
|
||||
.pipe(gulpFunction(afterFunction,"atEnd"))
|
||||
.pipe(gulpFunction(timeoutFunction,"atEnd"));
|
||||
|
||||
stream.on("finish",function(){
|
||||
beautylog.info("stream finished");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# Test.md
|
||||
This is a test file for the test.js gulp pipeline
|
||||
@@ -1,2 +0,0 @@
|
||||
# Test.md
|
||||
This is another test file for the test.js gulp pipeline
|
||||
@@ -0,0 +1 @@
|
||||
# the 1st testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the second testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the third testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the fourth testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the fifth testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the sixth testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the seventh testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the eighth testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the nineth testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the tenth testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the eleventh testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the twelveth testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the second testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the second testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the second testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the second testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the second testfile
|
||||
@@ -0,0 +1 @@
|
||||
# the 18th testfile
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/gulp-function',
|
||||
version: '3.0.8',
|
||||
description: 'A Gulp plugin to execute functions within a Gulp task pipeline.'
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/// <reference path="typings/main.d.ts" />
|
||||
|
||||
export let Q = require("q");
|
||||
export let through2 = require("through2");
|
||||
+76
-40
@@ -1,65 +1,101 @@
|
||||
/// <reference path="typings/main.d.ts" />
|
||||
import type { Transform } from 'node:stream';
|
||||
import through2 from 'through2';
|
||||
|
||||
import plugins = require("./gulpfunction.plugins");
|
||||
export type TExecutionMode = 'forEach' | 'forFirst' | 'atEnd';
|
||||
export type TGulpFunctionEncoding = BufferEncoding | string | null;
|
||||
export type TGulpFunctionResult = PromiseLike<unknown> | unknown;
|
||||
|
||||
export interface IPromiseFunction<TFile = unknown> {
|
||||
(file?: TFile | null, enc?: TGulpFunctionEncoding): TGulpFunctionResult;
|
||||
}
|
||||
|
||||
type TTransformCallback = (errorArg?: Error | null, dataArg?: unknown) => void;
|
||||
type TFlushCallback = (errorArg?: Error | null) => void;
|
||||
|
||||
const normalizeError = (errorArg: unknown): Error => {
|
||||
return errorArg instanceof Error ? errorArg : new Error(String(errorArg));
|
||||
};
|
||||
|
||||
module.exports = function (functionsToExecuteArg:any|any[],executionModeArg:string = 'forEach') {
|
||||
//important vars
|
||||
let executionMode = executionModeArg; //can be forEach or atEnd
|
||||
let functionsToExecute = functionsToExecuteArg;
|
||||
let promiseArray = [];
|
||||
let runFunction = function(functionArg){
|
||||
let returnValue = functionArg();
|
||||
if (typeof returnValue !== "undefined" && typeof returnValue.then !== "undefined") {
|
||||
promiseArray.push(returnValue);
|
||||
}
|
||||
const defaultExport = <TFile = unknown>(
|
||||
functionsToExecuteArg: IPromiseFunction<TFile> | Array<IPromiseFunction<TFile>>,
|
||||
executionModeArg: TExecutionMode = 'forEach'
|
||||
): Transform => {
|
||||
const runFunction = async (
|
||||
functionArg: IPromiseFunction<TFile>,
|
||||
fileArg: TFile | null,
|
||||
encArg: TGulpFunctionEncoding
|
||||
): Promise<void> => {
|
||||
await functionArg(fileArg, encArg);
|
||||
};
|
||||
|
||||
let checkAndRunFunction = function () {
|
||||
if (typeof functionsToExecute === "function" ) {
|
||||
runFunction(functionsToExecute);
|
||||
} else if (Array.isArray(functionsToExecute)) {
|
||||
for (let anyFunction in functionsToExecute) {
|
||||
runFunction(functionsToExecute[anyFunction]);
|
||||
}
|
||||
const checkAndRunFunction = async (
|
||||
fileArg: TFile | null,
|
||||
encArg: TGulpFunctionEncoding
|
||||
): Promise<void> => {
|
||||
if (typeof functionsToExecuteArg === 'function') {
|
||||
await runFunction(functionsToExecuteArg, fileArg, encArg);
|
||||
} else if (Array.isArray(functionsToExecuteArg)) {
|
||||
await Promise.all(
|
||||
functionsToExecuteArg.map(async (functionArg) => runFunction(functionArg, fileArg, encArg))
|
||||
);
|
||||
} else {
|
||||
throw new Error("gulp-callfunction: something is strange with the given arguments");
|
||||
throw new Error('gulp-callfunction: something is strange with the given arguments');
|
||||
}
|
||||
return plugins.Q.all(promiseArray);
|
||||
};
|
||||
|
||||
let hasExecutedOnce = false;
|
||||
let forEach = function (file, enc, cb) { //the forEach function is called for every chunk
|
||||
switch (executionMode){
|
||||
case "forEach":
|
||||
checkAndRunFunction().then(function(){
|
||||
cb(null, file);
|
||||
});
|
||||
const transformFunction = (fileArg: TFile, encArg: BufferEncoding, cbArg: TTransformCallback) => {
|
||||
switch (executionModeArg) {
|
||||
case 'forEach':
|
||||
checkAndRunFunction(fileArg, encArg).then(
|
||||
() => cbArg(null, fileArg),
|
||||
(errorArg) => cbArg(normalizeError(errorArg))
|
||||
);
|
||||
break;
|
||||
case "forFirst":
|
||||
!hasExecutedOnce ? checkAndRunFunction().then(function(){
|
||||
cb(null, file);
|
||||
}) : cb(null, file);
|
||||
case 'forFirst':
|
||||
if (!hasExecutedOnce) {
|
||||
hasExecutedOnce = true;
|
||||
checkAndRunFunction(fileArg, encArg).then(
|
||||
() => cbArg(null, fileArg),
|
||||
(errorArg) => cbArg(normalizeError(errorArg))
|
||||
);
|
||||
} else {
|
||||
cbArg(null, fileArg);
|
||||
}
|
||||
break;
|
||||
case "atEnd":
|
||||
cb(null, file);
|
||||
case 'atEnd':
|
||||
cbArg(null, fileArg);
|
||||
break;
|
||||
default:
|
||||
cbArg(null, fileArg);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
let atEnd = function(cb) {
|
||||
if (executionMode === "atEnd") {
|
||||
checkAndRunFunction().then(function(){
|
||||
cb();
|
||||
});
|
||||
const flushFunction = (cbArg: TFlushCallback) => {
|
||||
if (executionModeArg === 'atEnd') {
|
||||
checkAndRunFunction(null, null).then(
|
||||
() => cbArg(),
|
||||
(errorArg) => cbArg(normalizeError(errorArg))
|
||||
);
|
||||
} else {
|
||||
cb();
|
||||
cbArg();
|
||||
}
|
||||
};
|
||||
return plugins.through2.obj(forEach,atEnd);
|
||||
|
||||
return through2.obj(transformFunction, flushFunction) as Transform;
|
||||
};
|
||||
|
||||
export const forEach = <TFile = unknown>(funcArg: IPromiseFunction<TFile>): Transform => {
|
||||
return defaultExport(funcArg, 'forEach');
|
||||
};
|
||||
|
||||
export const forFirst = <TFile = unknown>(funcArg: IPromiseFunction<TFile>): Transform => {
|
||||
return defaultExport(funcArg, 'forFirst');
|
||||
};
|
||||
|
||||
export const atEnd = <TFile = unknown>(funcArg: IPromiseFunction<TFile>): Transform => {
|
||||
return defaultExport(funcArg, 'atEnd');
|
||||
};
|
||||
|
||||
export default defaultExport;
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"version": "v4",
|
||||
"repo": "borisyankov/DefinitelyTyped",
|
||||
"ref": "master",
|
||||
"path": "typings",
|
||||
"bundle": "typings/tsd.d.ts",
|
||||
"installed": {
|
||||
"node/node.d.ts": {
|
||||
"commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63"
|
||||
},
|
||||
"colors/colors.d.ts": {
|
||||
"commit": "3191f6e0088eee07c4d8fd24e4d27a40a60d9eb9"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"ambientDependencies": {
|
||||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts",
|
||||
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
||||
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"noImplicitAny": true,
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user