Compare commits

...

20 Commits

Author SHA1 Message Date
jkunz c560ac850b v3.0.4 2026-05-01 18:49:10 +00:00
jkunz add1cad575 fix(esm): improve ESM compatibility and modernize package configuration 2026-05-01 18:49:10 +00:00
jkunz 319011b8ff chore: remove .gitlab-ci.yml 2026-03-01 18:57:45 +00:00
philkunz 83bcdc4eb0 update description 2024-05-29 14:16:25 +02:00
philkunz 5c2f318158 3.0.3 2024-05-14 19:28:39 +02:00
philkunz e8043c5734 fix(core): update 2024-05-14 19:28:39 +02:00
philkunz b9805efa57 update tsconfig 2024-04-14 18:21:57 +02:00
philkunz a52a4ab7fd update tsconfig 2024-04-01 21:41:12 +02:00
philkunz ea609f83d7 update npmextra.json: githost 2024-04-01 19:59:44 +02:00
philkunz 3db25512ee update npmextra.json: githost 2024-03-30 21:48:44 +01:00
philkunz 5c2e3fea6c 3.0.2 2022-07-28 23:14:25 +02:00
philkunz 7e5178d825 fix(core): update 2022-07-28 23:14:25 +02:00
philkunz 9795489d67 3.0.1 2022-07-28 23:03:29 +02:00
philkunz 28733cbd73 fix(core): update 2022-07-28 23:03:29 +02:00
philkunz f12335ea62 3.0.0 2022-07-28 22:35:17 +02:00
philkunz f12a92660f BREAKING CHANGE(core): switch to esm 2022-07-28 22:35:16 +02:00
philkunz c81800cfab 2.0.9 2019-08-23 00:30:02 +02:00
philkunz 05b94469b5 fix(core): update 2019-08-23 00:30:01 +02:00
philkunz eda415893c 2.0.8 2019-08-22 10:42:47 +02:00
philkunz 630b7661d9 fix(core): update 2019-08-22 10:42:47 +02:00
25 changed files with 22591 additions and 1376 deletions
+1 -3
View File
@@ -15,8 +15,6 @@ node_modules/
# builds # builds
dist/ dist/
dist_web/ dist_*/
dist_serve/
dist_ts_web/
# custom # custom
-121
View File
@@ -1,121 +0,0 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
variables:
GIT_STRATEGY: clone
cache:
paths:
- .npmci_cache/
key: "$CI_BUILD_STAGE"
stages:
- security
- test
- release
- metadata
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
tags:
- docker
- notpriv
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- docker
- notpriv
# ====================
# test stage
# ====================
testLTS:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- priv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
release:
stage: release
script:
- npmci node install lts
- npmci npm publish
only:
- tags
tags:
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
script:
- npmci command npm install -g tslint typescript
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- docker
- notpriv
pages:
image: hosttoday/ht-docker-dbase:npmci
services:
- docker:18-dind
stage: metadata
script:
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
allow_failure: true
+38
View File
@@ -0,0 +1,38 @@
{
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmRegistryUrl": "registry.npmjs.org"
},
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartspawn",
"shortDescription": "smart subprocess handling",
"description": "A node module for smart subprocess handling with support for promises and streamlined subprocess communication.",
"npmPackagename": "@push.rocks/smartspawn",
"license": "MIT",
"keywords": [
"subprocess",
"child_process",
"spawn",
"threading",
"multithreading",
"process management",
"async",
"promise"
]
},
"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 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"
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}
+26
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"]
}
}
}
}
}
}
]
}
-52
View File
@@ -1,52 +0,0 @@
# @pushrocks/smartspawn
smart subprocess handling
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartspawn)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartspawn)
* [github.com (source mirror)](https://github.com/pushrocks/smartspawn)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartspawn/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartspawn/badges/master/build.svg)](https://gitlab.com/pushrocks/smartspawn/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartspawn/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartspawn/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartspawn.svg)](https://www.npmjs.com/package/@pushrocks/smartspawn)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartspawn/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartspawn)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
## Usage
Use TypeScript for best in class instellisense.
### Understand the Purpose
smartipc makes it easy to spawn tasks into subprocesses without loosing control over what those processes do.
You can transparently call functions and expect returned data using promises.
### How To
**Master.ts:**
```javascript
import * as smartspawn from 'smartspawn';
smartspawn.setBasePathArg(__dirname); // if you want to avoid typings out full paths every time
let myThread = new smartspawn.Thread('worker');
myThread.send('someMessageOrObject').then(messageResponse => {
console.log(messageResponse);
});
```
**worker.ts**
```javascript
```
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)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
+1 -1
View File
@@ -1,2 +1,2 @@
require('@gitzone/tsrun'); require('@git.zone/tsrun');
require('spawn-wrap').runMain() require('spawn-wrap').runMain()
+81
View File
@@ -0,0 +1,81 @@
# Changelog
## 2026-05-01 - 3.0.4 - fix(esm)
improve ESM compatibility and modernize package configuration
- replace direct CommonJS-style imports of threads and spawn-wrap with createRequire-based loading for NodeNext compatibility
- update internal path handling to derive package paths from import.meta.url instead of __dirname
- add package exports entry, tighten TypeScript settings, and refresh test/tooling configuration for the current build setup
## 2026-03-01 - 3.0.3 - maintenance
Released 3.0.3 with repository and metadata housekeeping updates.
- Removed the GitLab CI configuration.
- Updated the project description.
- Included minor maintenance-only changes across the 3.0.3 release line.
## 2024-05-14 - 3.0.2 - core
Delivered a core update in 3.0.2 with additional configuration maintenance.
- Updated core functionality.
- Refreshed TypeScript configuration.
- Updated npm metadata for git host settings.
- Summarizes minor maintenance commits within the 3.0.2 release range.
## 2022-07-28 - 3.0.0 - core
Released the 3.x line with a breaking module-system migration and follow-up core fixes through 3.0.13.0.2.
- Switched the package to ESM as a breaking change.
- Applied core update fixes in 3.0.0, 3.0.1, and 3.0.2.
- Summarizes the trivial version-tag commits across versions 3.0.0 through 3.0.2.
## 2019-08-22 - 2.0.9 - core
Delivered a sequence of core maintenance releases from 2.0.3 through 2.0.9.
- Applied repeated core update fixes across versions 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, and 2.0.8.
- Released 2.0.9 as the latest point in this maintenance range.
- Summarizes trivial version-only commits across versions 2.0.3 through 2.0.9.
## 2018-08-07 - 2.0.0 - package
Released 2.0.0 with package-level breaking and follow-up maintenance changes through 2.0.2.
- Introduced a breaking package scope change in the lead-up to 2.0.0.
- Updated npm access level for the package.
- Updated the testing framework in 2.0.1.
- Summarizes trivial version-only commits across versions 2.0.0 through 2.0.2.
## 2017-11-28 - 1.0.9 - maintenance
Published maintenance updates across versions 1.0.9 through 1.0.11.
- Updated the project to align with newer standards.
- Refreshed CI configuration.
- Summarizes trivial version-only commits across versions 1.0.9 through 1.0.11.
## 2017-03-04 - 1.0.4 - core
Expanded core threading and API capabilities across versions 1.0.4 through 1.0.8.
- Added simple forking support with `threadsimple`.
- Changed `ThreadSimple` to return a Promise.
- Improved typings.
- Added `forkOptions`.
- Added `argvArgs` support to `simpleThread`.
- Included an update to wrapping behavior.
- Summarizes trivial version-only commits across versions 1.0.4 through 1.0.8.
## 2017-03-03 - 1.0.2 - maintenance
Delivered early maintenance improvements across versions 1.0.2 and 1.0.3.
- Updated internal `smartipc` code.
- Updated the README.
- Added `npmts` as a required global CI tool.
- Summarizes trivial version-only commits across versions 1.0.2 through 1.0.3.
## 2017-01-29 - 1.0.0 - core
Initial release of the project with foundational functionality and setup work through 1.0.1.
- Added the initial basic functionality.
- Started the implementation and merged initial development work.
- Added and improved the README.
- Added GitLab CI configuration.
- Switched to native IPC to reduce dependencies.
- Summarizes trivial release-tag and documentation-only follow-up commits across versions 1.0.0 and 1.0.1.
+19
View File
@@ -0,0 +1,19 @@
Copyright (c) 2026 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
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+29 -12
View File
@@ -1,21 +1,38 @@
{ {
"npmts": { "@ship.zone/szci": {
"testTs": {
"./test/*.ts": "./test/"
}
},
"npmci": {
"npmGlobalTools": [], "npmGlobalTools": [],
"npmAccessLevel": "public" "npmRegistryUrl": "registry.npmjs.org"
}, },
"gitzone": { "@git.zone/cli": {
"projectType": "npm",
"module": { "module": {
"githost": "gitlab.com", "githost": "code.foss.global",
"gitscope": "pushrocks", "gitscope": "push.rocks",
"gitrepo": "smartspawn", "gitrepo": "smartspawn",
"shortDescription": "smart subprocess handling", "shortDescription": "smart subprocess handling",
"npmPackagename": "@pushrocks/smartspawn", "description": "A node module for smart subprocess handling with support for promises and streamlined subprocess communication.",
"license": "MIT" "npmPackagename": "@push.rocks/smartspawn",
"license": "MIT",
"keywords": [
"subprocess",
"child_process",
"spawn",
"threading",
"multithreading",
"process management",
"async",
"promise"
]
},
"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 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"
} }
} }
+14104 -1120
View File
File diff suppressed because it is too large Load Diff
+45 -28
View File
@@ -1,48 +1,65 @@
{ {
"name": "@pushrocks/smartspawn", "name": "@push.rocks/smartspawn",
"version": "2.0.7", "version": "3.0.4",
"private": false, "private": false,
"description": "smart subprocess handling", "description": "A node module for smart subprocess handling with support for promises and streamlined subprocess communication.",
"main": "dist/index.js", "exports": {
"typings": "dist/index.d.ts", ".": "./dist_ts/index.js"
},
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "tstest test/",
"build": "(tsbuild)" "build": "tsbuild",
"buildDocs": "tsdoc"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+ssh://git@gitlab.com/pushrocks/smartipc.git" "url": "https://code.foss.global/push.rocks/smartspawn.git"
}, },
"author": "Lossless GmbH", "author": "Task Venture Capital GmbH <hello@task.vc>",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://gitlab.com/pushrocks/smartipc/issues" "url": "https://code.foss.global/push.rocks/smartspawn/issues"
}, },
"homepage": "https://gitlab.com/pushrocks/smartipc#README", "homepage": "https://code.foss.global/push.rocks/smartspawn",
"dependencies": { "dependencies": {
"@pushrocks/smartpromise": "^3.0.2", "@push.rocks/smartpromise": "^4.2.4",
"spawn-wrap": "^1.4.2", "spawn-wrap": "^3.0.0",
"threads": "1.0.0-beta.4", "threads": "1.7.0",
"tiny-worker": "^2.2.0" "tiny-worker": "^2.3.0"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.11", "@git.zone/tsbuild": "^4.4.0",
"@gitzone/tsrun": "^1.2.8", "@git.zone/tstest": "^3.6.3",
"@gitzone/tstest": "^1.0.24", "@types/node": "^25.6.0"
"@pushrocks/tapbundle": "^3.0.11",
"@types/node": "^12.7.2",
"tslint": "^5.19.0",
"tslint-config-prettier": "^1.18.0"
}, },
"files": [ "files": [
"ts/*", "ts/**/*",
"ts_web/*", "ts_web/**/*",
"dist/*", "dist/**/*",
"dist_web/*", "dist_*/**/*",
"dist_ts_web/*", "dist_ts/**/*",
"assets/*", "dist_ts_web/**/*",
"assets/**/*",
"cli.js", "cli.js",
".smartconfig.json",
"license",
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
],
"browserslist": [
"last 1 chrome versions"
],
"keywords": [
"subprocess",
"child_process",
"spawn",
"threading",
"multithreading",
"process management",
"async",
"promise"
] ]
} }
+8036
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -0,0 +1 @@
+120
View File
@@ -0,0 +1,120 @@
Given the provided files and their contents, the comprehensive documentation for using **`@push.rocks/smartspawn`** with TypeScript and in a manner that provides thorough examples and descriptions of features and scenarios is extensive. However, I'll outline a concise and informative usage guide that can serve as a helpful starting point. For an in-depth understanding and a complete reference to all features, further reading, exploration, and experimentation with the library are recommended.
# @push.rocks/smartspawn
smart subprocess handling
## Install
To install `@push.rocks/smartspawn`, open your terminal and run the following command:
```bash
npm install @push.rocks/smartspawn
```
This command fetches the package from npm and adds it to your project's dependencies.
## Usage
This guide uses TypeScript and ESM syntax to demonstrate how to utilize `@push.rocks/smartspawn` for smart subprocess handling in your application.
First, ensure that your TypeScript environment is set up to support ECMAScript modules (ESM). Your `tsconfig.json` should include:
```json
{
"compilerOptions": {
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "node"
}
}
```
### Starting and Stopping a Simple Thread
`ThreadSimple` class allows you to manage subprocesses effectively. Here's how to start and stop a simple thread:
```typescript
// Import the necessary components from the library
import { ThreadSimple } from '@push.rocks/smartspawn';
// Define a function that creates, starts, and stops a thread
async function demonstrateThreadSimple() {
// Create an instance of ThreadSimple
const mySimpleThread = new ThreadSimple('./path/to/worker.js');
// Start the thread
await mySimpleThread.start();
console.log('Thread has started.');
// Stop the thread
await mySimpleThread.stop();
console.log('Thread has stopped.');
}
// Call the function to demonstrate its functionality
demonstrateThreadSimple();
```
The `./path/to/worker.js` should be the path to your worker script that you want to execute in a separate process.
### Wrapping Processes
`smartspawn` also provides functionality to wrap subprocesses, allowing you to modify or set up an environment before execution. Here's how to wrap and unwrap subprocesses:
```typescript
import { startSpawnWrap, endSpawnWrap } from '@push.rocks/smartspawn';
// Start a wrap
startSpawnWrap('path/to/script', ['arg1', 'arg2'], { ENV_VAR: 'value' });
console.log('Subprocess wrapped.');
// End the wrap when it's no longer needed
endSpawnWrap();
console.log('Subprocess unwrapped.');
```
### Advanced Thread Management
`@push.rocks/smartspawn` integrates with the `threads` package to provide advanced threading capabilities. Here's a brief example showing how you might utilize it for more complex scenarios:
```typescript
import { Thread, spawn, Worker } from 'threads';
async function advancedThreadExample() {
const thread = await spawn(new Worker('./worker'));
const result = await thread.doWork();
console.log(`Result from thread: ${result}`);
await Thread.terminate(thread);
}
advancedThreadExample();
```
Ensure you explore the `threads` documentation for a more detailed understanding of creating workers and communicating between the main process and threads.
### Conclusion
The `@push.rocks/smartspawn` package simplifies managing subprocesses in your Node.js applications, offering straightforward APIs for starting, stopping, and communicating with child processes. Whether you need to execute a simple script in the background or leverage sophisticated multi-threading capabilities, `smartspawn` provides the tools necessary to implement these features efficiently and robustly.
Remember, the examples above are starting points. Review the source code, tests, and type declarations for a comprehensive understanding of everything `@push.rocks/smartspawn` and its integrated packages can do. Experiment with the library in your projects to best learn how to utilize its full potential in real-world applications.
## 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.
+7
View File
@@ -0,0 +1,7 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as smartspawn from '../ts/index.js';
tap.test('should create a simple test function', async () => {});
export default tap.start();
-7
View File
@@ -1,7 +0,0 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartspawn from '../ts/index';
tap.test('should create a simple test function', async () => {});
tap.start();
+8
View File
@@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartspawn',
version: '3.0.4',
description: 'A node module for smart subprocess handling with support for promises and streamlined subprocess communication.'
}
+32 -3
View File
@@ -1,4 +1,33 @@
export * from './smartspawn.classes.threadsimple'; export * from './smartspawn.classes.threadsimple.js';
export * from './smartspawn.wrap'; export * from './smartspawn.wrap.js';
export * from 'threads'; import { createRequire } from 'module';
const require = createRequire(import.meta.url);
export interface IThreadsModule {
BlobWorker: new (...args: unknown[]) => unknown;
DefaultSerializer: unknown;
Pool: unknown;
Thread: {
terminate: (threadArg: unknown) => Promise<void> | void;
events?: (threadArg: unknown) => unknown;
};
Transfer: (payloadArg: unknown, transferablesArg?: Transferable[]) => unknown;
Worker: new (workerPathArg: string | URL, optionsArg?: unknown) => unknown;
registerSerializer: (serializerArg: unknown) => void;
spawn: <T = unknown>(workerArg: unknown, optionsArg?: unknown) => Promise<T>;
}
const threads = require('threads') as IThreadsModule;
export const {
BlobWorker,
DefaultSerializer,
Pool,
Thread,
Transfer,
Worker,
registerSerializer,
spawn,
} = threads;
+1 -3
View File
@@ -1,10 +1,8 @@
import * as plugins from './smartspawn.plugins';
import * as smartpromise from '@pushrocks/smartpromise';
import * as childProcess from 'child_process'; import * as childProcess from 'child_process';
export class ThreadSimple { export class ThreadSimple {
public workerPath: string; public workerPath: string;
public threadChildProcess: childProcess.ChildProcess; public threadChildProcess!: childProcess.ChildProcess;
public forkOptions: childProcess.ForkOptions; public forkOptions: childProcess.ForkOptions;
public argvArgs: string[]; public argvArgs: string[];
constructor( constructor(
+2 -2
View File
@@ -1,4 +1,4 @@
import * as plugins from './smartspawn.plugins'; import * as plugins from './smartspawn.plugins.js';
export const packageBase = plugins.path.join(__dirname, '../'); export const packageBase = plugins.path.join(plugins.path.dirname(plugins.url.fileURLToPath(import.meta.url)), '../');
export const typescriptwrapJs = plugins.path.join(packageBase, 'assets/typescriptwrap.js'); export const typescriptwrapJs = plugins.path.join(packageBase, 'assets/typescriptwrap.js');
+3 -3
View File
@@ -1,5 +1,5 @@
import * as path from 'path'; import * as path from 'path';
const threads = require('threads'); import * as url from 'url';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@push.rocks/smartpromise';
export { path, smartpromise, threads }; export { path, smartpromise, url };
+9 -3
View File
@@ -1,8 +1,14 @@
import * as spawnWrap from 'spawn-wrap'; import { createRequire } from 'module';
let unwrap: any = null; const require = createRequire(import.meta.url);
const spawnWrap = require('spawn-wrap') as (
spawnArgvArg: string[],
envArg?: NodeJS.ProcessEnv,
) => () => void;
export const startSpawnWrap = (filePath: string, cliArgs: string[] = [], envArgs: any = {}) => { let unwrap: (() => void) | null = null;
export const startSpawnWrap = (filePath: string, cliArgs: string[] = [], envArgs: NodeJS.ProcessEnv = {}) => {
const spawnArray = [filePath]; const spawnArray = [filePath];
for (const cliArg of cliArgs) { for (const cliArg of cliArgs) {
spawnArray.push(cliArg); spawnArray.push(cliArg);
+16
View File
@@ -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"
]
}
-17
View File
@@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}