{"id":13602545,"url":"https://github.com/yan-foto/electron-reload","last_synced_at":"2025-04-08T02:42:20.105Z","repository":{"id":36111212,"uuid":"40413169","full_name":"yan-foto/electron-reload","owner":"yan-foto","description":"Simplest (:pray:) way to reload an electron app on file changes!","archived":false,"fork":false,"pushed_at":"2023-04-20T13:22:39.000Z","size":203,"stargazers_count":520,"open_issues_count":19,"forks_count":54,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-01T01:42:16.435Z","etag":null,"topics":["electron","electron-reload","refreshes"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/electron-reload","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yan-foto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-08-08T18:50:31.000Z","updated_at":"2025-03-02T21:13:22.000Z","dependencies_parsed_at":"2024-01-14T16:55:19.043Z","dependency_job_id":null,"html_url":"https://github.com/yan-foto/electron-reload","commit_stats":{"total_commits":84,"total_committers":12,"mean_commits":7.0,"dds":"0.26190476190476186","last_synced_commit":"a0d48932f4b6b36f022eff10347e8b0fa0b27abc"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yan-foto%2Felectron-reload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yan-foto%2Felectron-reload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yan-foto%2Felectron-reload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yan-foto%2Felectron-reload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yan-foto","download_url":"https://codeload.github.com/yan-foto/electron-reload/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767232,"owners_count":20992538,"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":["electron","electron-reload","refreshes"],"created_at":"2024-08-01T18:01:27.175Z","updated_at":"2025-04-08T02:42:20.079Z","avatar_url":"https://github.com/yan-foto.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# electron reload\nThis is (*hopefully*) the simplest way to load contents of all active [`BrowserWindow`s](https://github.com/atom/electron/blob/master/docs/api/browser-window.md) within electron when the source files are changed.\n\n[![Linting](https://github.com/yan-foto/electron-reload/actions/workflows/node.js.yml/badge.svg)](https://github.com/yan-foto/electron-reload/actions/workflows/node.js.yml)\n[![npm](https://img.shields.io/npm/v/electron-reload.svg)](https://www.npmjs.com/package/electron-reload)\n[![Code Climate](https://codeclimate.com/github/yan-foto/electron-reload/badges/gpa.svg)](https://codeclimate.com/github/yan-foto/electron-reload)\n[![Known Vulnerabilities](https://snyk.io/test/github/yan-foto/electron-reload/badge.svg)](https://snyk.io/test/github/yan-foto/electron-reload)\n![license](https://img.shields.io/npm/l/electron-reload.svg)\n\n# Installation\n```\nnpm install electron-reload\n```\n\n# Usage\nJust initialize this module with desired glob or file path to watch and let it refresh electron browser windows as targets are changed:\n\n```js\n'use strict';\n\nconst {app, BrowserWindow} = require('electron');\n\nconst electronReload = require('electron-reload')\n\n// Standard stuff\napp.on('ready', () =\u003e {\n  let mainWindow = new BrowserWindow({width: 800, height: 600});\n\n  mainWindow.loadUrl(`file://${__dirname}/index.html`);\n  // the rest...\n});\n```\n\nNote that the above code only refreshes `WebContent`s of all `BrowserWindow`s. So if you want to have a hard reset (starting a new electron process) you can just pass the path to the electron executable in the `options` object:\n\n```js\nconst path = require('path')\n\nrequire('electron-reload')(__dirname, {\n  electron: path.join(__dirname, 'node_modules', '.bin', 'electron')\n});\n```\n\nIf your app overrides some of the default `quit` or `close` actions (e.g. closing the last app window hides the window instead of quitting the app) then the default `electron-reload` hard restart could leave you with multiple instances of your app running. In these cases you can change the default hard restart action from `app.quit()` to `app.exit()` by specifying the hard reset method in the electron-reload options:\n\n```js\nconst path = require('path')\n\nrequire('electron-reload')(__dirname, {\n  electron: path.join(__dirname, 'node_modules', '.bin', 'electron'),\n  hardResetMethod: 'exit'\n});\n```\n\n# API\n`electron_reload(paths, options)`\n* `paths`: a file, directory or glob pattern to watch\n* `options` (optional) containing:\n  - [`chokidar`](https://github.com/paulmillr/chokidar) options\n  - `electron` property pointing to electron executables.\n  - `electronArgv` string array with command line options passed to the Electron executable. Only used when hard resetting.\n  - `appArgv`: string array with command line options passed to the Electron app. Only used when hard resetting.\n  - `forceHardReset`: enables hard reset for **every** file change and not only the main file\n\n  `options` will default to `{ignored: /node_modules|[\\/\\\\]\\./, argv: []}`.\n\n\n# Why this module?\nSimply put, I was tired and confused by all other available modules which are so complicated\\* for such an uncomplicated task!\n\n\\* *e.g. start a local HTTP server, publish change events through a WebSocket, etc.!*\n\n# Changelog\n - **2.0.0-alpha.1**:\n   - Update outdated dependencies.\n   - Fix #35: throw error instead of logging to console.\n   - Fix #65: add TypeScript definitions.\n   - Fix #78: minor README fixes.\n   - Fix #87: enable passing arguments to the app itself.\n - **1.5.0**:\n   - Upgrade `chokidar` from v2 to v3 (lighter/faster installation)\n   - Add friendly linting in dev mode (`node run lint`) and fix CI linting issues (see [#62](https://github.com/yan-foto/electron-reload/pull/62))\n - **1.4.1**: Fix two minor bugs\n   - Wrong globbing when doing hard reset ([`#58`](https://github.com/yan-foto/electron-reload/issues/58))\n   - Issues with locating main file in specific project structures ([`#57`](https://github.com/yan-foto/electron-reload/issues/57))\n - **1.4.0**: Enable hard reset for all changes (and not only the main file)\n - **1.3.0**: Allow passing arguments to electron executable upon hard resets\n - **1.2.5**: Upgrade dependencies (fix vulnerabilities)\n - **1.2.4**: Use `index.js` as fallback if `main` is not defined in `package.json`\n - **1.2.3**: Fix multiple instances on restart\n - **1.2.2**: Fix `browserWindows[]` indexing\n - **1.2.1**: Remove logging from production code (d'oh)\n - **1.2.0**: Allow hard reset in multiple browser windows\n - **1.1.0**: Add `app.exit()` in addition to `app.quit()` for hard resets\n - **1.0.3**: Fix hard reset bug\n - **1.0.2**: Detach child so that killing parent doesn't kill it (on windows)\n - **1.0.1**: Replace `extend` with `Object.assign`\n - **1.0.0**: Adapt to Electron 1.0 new API\n - **0.3.0**: Use new method of accessing `app` (e.g. `require(electron).app`)\n - **0.2.0**: Use new electrons (\u003e v0.32.3) `browser-window-created` event\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyan-foto%2Felectron-reload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyan-foto%2Felectron-reload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyan-foto%2Felectron-reload/lists"}