Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcello3d/headless-electron
Run node scripts in a headless electron environment
https://github.com/marcello3d/headless-electron
Last synced: 15 days ago
JSON representation
Run node scripts in a headless electron environment
- Host: GitHub
- URL: https://github.com/marcello3d/headless-electron
- Owner: marcello3d
- License: mit
- Created: 2022-07-19T03:12:01.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-28T00:09:40.000Z (over 1 year ago)
- Last Synced: 2024-04-14T01:06:37.880Z (7 months ago)
- Language: TypeScript
- Homepage:
- Size: 358 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# headless-electron
> Run scripts from node in an Electron pool
[![Build Status](https://github.com/marcello3d/headless-electron/workflows/build/badge.svg)](https://github.com/marcello3d/headless-electron/actions)
[![npm](https://img.shields.io/npm/v/headless-electron.svg)](https://www.npmjs.com/package/headless-electron)
[![npm](https://img.shields.io/npm/dm/headless-electron.svg)](https://www.npmjs.com/package/headless-electron)## Usage
```typescript
const ep = new ElectronProcess();
const result = await ep.runScript({
pathname: path.resolve(__dirname, "typescript.ts"),
functionName: "multiply",
args: [2, 3],
});
await ep.kill();
```## API
```typescript
interface ElectronProcess {
constructor(options: {
debugMode: boolean; // true will show the Electron BrowserWindow for debugging purposes
concurrency: number; // maximum number of Electron BrowserWindows to create for parallel runs
});runScript(options: {
pathname: string; // full path to script to require
functionName?: string; // function name to call, defaults to 'default'
args?: any[]; // arguments passed to function
}): Promise; // returns what the function returns
}
```## Acknowledgements
Based on [jest-electron](https://github.com/hustcc/jest-electron)
## License
MIT