npm.io
0.7.0 • Published 3 years ago

headless-electron

Licence
MIT
Version
0.7.0
Deps
0
Size
57 kB
Vulns
0
Weekly
0
Stars
1

headless-electron

Run scripts from node in an Electron pool

Build Status npm npm

Usage

const ep = new ElectronProcess();
const result = await ep.runScript({
  pathname: path.resolve(__dirname, "typescript.ts"),
  functionName: "multiply",
  args: [2, 3],
});
await ep.kill();

API

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

License

MIT

Keywords