# headless-electron

> Manage a headless instance of Electron to run logic in tests and on the server

Latest version **0.7.0** (published 2023-03-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install headless-electron
pnpm add headless-electron
yarn add headless-electron
bun add headless-electron
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.0 |
| Published | 2023-03-28 |
| First published | 2022-07-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 56.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | descript-dev |
| Keywords | headless, electron |

## Links

- npm: https://www.npmjs.com/package/headless-electron
- Repository: https://github.com/marcello3d/headless-electron
- Homepage: https://github.com/marcello3d/headless-electron#readme
- Issues: https://github.com/marcello3d/headless-electron/issues
- npm.io page: https://npm.io/package/headless-electron

## Recent versions

- 0.7.0 (latest) — 2023-03-28
- 0.6.0 — 2022-09-09
- 0.5.0 — 2022-09-09
- 0.4.1 — 2022-09-09
- 0.4.0 — 2022-09-09
- 0.3.0 — 2022-07-21
- 0.2.4 — 2022-07-21
- 0.2.3 — 2022-07-21
- 0.2.2 — 2022-07-21
- 0.2.1 — 2022-07-20
- 0.2.0 — 2022-07-20
- 0.1.1 — 2022-07-19
- 0.1.0 — 2022-07-19

## 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<any>; // returns what the function returns
}
```

## Acknowledgements

Based on [jest-electron](https://github.com/hustcc/jest-electron)

## License

MIT

---
_Source: https://npm.io/package/headless-electron · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
