https://github.com/matrixai/js-exec
Execute child process while replacing process-memory for TypeScript & JavaScript
https://github.com/matrixai/js-exec
exec execvp execvpe
Last synced: 12 months ago
JSON representation
Execute child process while replacing process-memory for TypeScript & JavaScript
- Host: GitHub
- URL: https://github.com/matrixai/js-exec
- Owner: MatrixAI
- License: apache-2.0
- Created: 2024-02-16T03:45:05.000Z (about 2 years ago)
- Default Branch: staging
- Last Pushed: 2024-03-18T04:04:44.000Z (almost 2 years ago)
- Last Synced: 2024-05-29T00:33:10.197Z (almost 2 years ago)
- Topics: exec, execvp, execvpe
- Language: JavaScript
- Homepage: https://polykey.com
- Size: 573 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# js-exec
This exposes `execvp` to Node.js. This allows running a child process that replaces the parent process image. This is not possible on Windows, if you run this on Windows, expect an exception!
## Installation
```sh
npm install --save @matrixai/exec
```
## Usage
exec can be used in the following way.
```ts
import { exec } from '@matrixai/exec';
// This should output the current enviroment while adding `test_env` to it.
exec.execvp(
'node',
[
'-e',
'console.log(process.env)',
],
{
test_env: 'this value'
},
);
```
Note that only linux and mac platforms are supported.
## Development
Run `nix develop`, and once you're inside, you can use:
```sh
# install (or reinstall packages from package.json)
npm install
# build the native objects
npm run prebuild
# build the dist and native objects
npm run build
# run the repl (this allows you to import from ./src)
npm run ts-node
# run the tests
npm run test
# lint the source code
npm run lint
# automatically fix the source
npm run lintfix
```
### Cargo/Rust targets
Cargo is a cross-compiler. The target structure looks like this:
```
---
```
For example:
```
x86_64-unknown-linux-gnu
x86_64-pc-windows-msvc
aarch64-apple-darwin
x86_64-apple-darwin
```
The available target list is in `rustc --print target-list`.
### Docs Generation
```sh
npm run docs
```
See the docs at: https://matrixai.github.io/js-exec/
### Publishing
Publishing is handled automatically by the staging pipeline.
Prerelease:
```sh
# npm login
npm version prepatch --preid alpha # premajor/preminor/prepatch
git push --follow-tags
```
Release:
```sh
# npm login
npm version patch # major/minor/patch
git push --follow-tags
```
Manually:
```sh
# npm login
npm version patch # major/minor/patch
npm run build
npm publish --access public
git push
git push --tags
```