{"id":13767023,"url":"https://github.com/juliangruber/electron-stream","last_synced_at":"2025-04-06T02:08:08.589Z","repository":{"id":1876933,"uuid":"45107603","full_name":"juliangruber/electron-stream","owner":"juliangruber","description":"Streaming wrapper around electron","archived":false,"fork":false,"pushed_at":"2023-10-05T18:59:02.000Z","size":325,"stargazers_count":128,"open_issues_count":10,"forks_count":18,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-30T01:05:58.378Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juliangruber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-10-28T11:22:19.000Z","updated_at":"2025-03-17T03:12:29.000Z","dependencies_parsed_at":"2024-01-02T21:20:13.527Z","dependency_job_id":"ac96ae76-cea4-4e46-b73d-531031a62f4e","html_url":"https://github.com/juliangruber/electron-stream","commit_stats":{"total_commits":123,"total_committers":13,"mean_commits":9.461538461538462,"dds":"0.19512195121951215","last_synced_commit":"5b15ceb758b2c0b78dfae02891a96bbf13566e51"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliangruber%2Felectron-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliangruber%2Felectron-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliangruber%2Felectron-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliangruber%2Felectron-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliangruber","download_url":"https://codeload.github.com/juliangruber/electron-stream/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423514,"owners_count":20936626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T16:01:03.663Z","updated_at":"2025-04-06T02:08:08.567Z","avatar_url":"https://github.com/juliangruber.png","language":"JavaScript","funding_links":[],"categories":["Tools","JavaScript"],"sub_categories":["Using Electron"],"readme":"\n# electron-stream\n\n  Write JavaScript to `electron`, get console output back!\n\n  [![downloads](https://img.shields.io/npm/dm/electron-stream.svg)](https://www.npmjs.org/package/electron-stream)\n\n## Example\n\n  Boot a hidden electron instance, log to stdout and clean up:\n\n```js\nvar electron = require('electron-stream');\n\nvar browser = electron();\n\nbrowser.pipe(process.stdout);\n\nbrowser.write('console.log(window.location.href);');\nbrowser.write('window.close();');\nbrowser.end();\n```\n\n  Alternatively, use an existing http server. Note you cannot write to electron-stream when outside http server is in use.\n\n```js\nvar electron = require('electron-stream');\nvar http = require('http');\n\nvar server = http.createServer((req, res) =\u003e {\n  if (/^\\/bundle\\.js/.test(req.url)) {\n    res.setHeader('content-type', 'application/javascript');\n    res.setHeader('cache-control', 'no-cache');\n    res.end('console.log(\"hello\");window.close();');\n    return;\n  }\n\n  if (req.url == '/') {\n    res.setHeader('Content-Type', 'text/html');\n    res.end(`\u003c!DOCTYPE html\u003e\u003cmeta charset=\"utf8\"\u003e\u003cbody\u003e\u003cscript src=\"/bundle.js\"\u003e\u003c/script\u003e\u003c/body\u003e`);\n    return;\n  }\n});\n\nserver.listen(8000);\nvar browser = electron({ loc: 'http://localhost:8000' });\nbrowser.pipe(process.stdout);\nbrowser.end();\n\n```\n\n## Output streams\n\n`electron-stream` lets you read all of the console output together, or split up into `stdout` and `stderr`:\n\n```js\n// console.log and console.error\nbrowser.pipe(...);\nbrowser.stdall.pipe(...);\n\n// console.log only\nbrowser.stdout.pipe(...);\n\n// console.error only\nbrowser.stderr.pipe(...);\n```\n\n## Installation\n\n  To install as a library:\n\n```bash\n$ npm install electron-stream\n```\n\n  To install as a binary:\n\n```bash\n$ npm install -g electron-stream\n$ echo \"console.log('foo');window.close()\" | electron-stream\n```\n\n## Travis\n\nTo use electron on travis, add this to your travis.yml:\n\n```yml\naddons:\n  apt:\n    packages:\n      - xvfb\ninstall:\n  - export DISPLAY=':99.0'\n  - Xvfb :99 -screen 0 1024x768x24 \u003e /dev/null 2\u003e\u00261 \u0026\n  - npm install\n```\n\n[Source](https://github.com/rhysd/Shiba/blob/055a11a0a2b4f727577fe61371a88d8db9277de5/.travis.yml).\n\n## API\n\n### electron([opts])\n\nCreate a writable stream around a newly spawned `electron` which forwards written data to `electron`. This module bundles [electron-prebuilt](https://npmjs.org/package/electron-prebuilt).\n\nOptions:\n\n  - `show`: Show the electron window. Defaults to `false`.\n  - `node`:  Enable node integration. Defaults to `false`.\n  - `basedir`: Set this if you need to require node modules in `node` mode\n  - `static`: Serve static files from this directory at `/`\n  - `loc`: a full url like `http://localhost:8080/` for using an existing http server. When `loc` is supplied, options `node`, `basedir`, and `static` are all ignored.\n  - `sandbox`: Run electron with sandbox. Disable to emit debug information when using Docker. Defaults to `true`.\n  \n### electron#stdout\n### electron#stderr\n### electron#stdall\n\nReadable streams containing the console output. `console.log` will be forwarded to `.stdout`, `console.error` to `.stderr`. `.stdall` has them both.\n\n### electron#kill()\n\nKill the child process.\n\n### electron#on('exit', fn)\n\nEmitted when the underlying `electron` exits. There can be multiple reasons for this:\n\n- `electron#kill()` was called\n- `window.close()` was sent as a script\n- there was a fatal error\n\n## License\n\n  MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliangruber%2Felectron-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliangruber%2Felectron-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliangruber%2Felectron-stream/lists"}