electron-reloader
Advanced tools
Comparing version 0.2.0 to 0.3.0
30
index.js
'use strict'; | ||
const {inspect} = require('util'); | ||
const path = require('path'); | ||
@@ -6,9 +7,11 @@ const electron = require('electron'); | ||
const isDev = require('electron-is-dev'); | ||
const dateTime = require('date-time'); | ||
const chalk = require('chalk'); | ||
function getMainProcessPaths(topModuleObj) { | ||
const cwd = path.dirname(topModuleObj.filename); | ||
const paths = new Set([topModuleObj.filename]); | ||
function getMainProcessPaths(topModuleObject) { | ||
const cwd = path.dirname(topModuleObject.filename); | ||
const paths = new Set([topModuleObject.filename]); | ||
const getPaths = moduleObj => { | ||
for (const child of moduleObj.children) { | ||
const getPaths = moduleObject => { | ||
for (const child of moduleObject.children) { | ||
if (path.relative(cwd, child.filename).includes('node_modules')) { | ||
@@ -23,3 +26,3 @@ continue; | ||
getPaths(topModuleObj); | ||
getPaths(topModuleObject); | ||
@@ -40,5 +43,6 @@ return paths; | ||
options = Object.assign({ | ||
watchRenderer: true | ||
}, options); | ||
options = { | ||
watchRenderer: true, | ||
...options | ||
}; | ||
@@ -61,3 +65,3 @@ const cwd = path.dirname(moduleObj.filename); | ||
watcher.on('ready', () => { | ||
console.log('Watched paths:', watcher.getWatched()); | ||
console.log('Watched paths:', inspect(watcher.getWatched(), {compact: false, colors: true})); | ||
}); | ||
@@ -68,3 +72,3 @@ } | ||
if (options.debug) { | ||
console.log('File changed:', filePath); | ||
console.log('File changed:', chalk.bold(filePath), chalk.dim(`(${dateTime().split(' ')[1]})`)); | ||
} | ||
@@ -76,4 +80,4 @@ | ||
} else { | ||
for (const win of electron.BrowserWindow.getAllWindows()) { | ||
win.webContents.reloadIgnoringCache(); | ||
for (const window_ of electron.BrowserWindow.getAllWindows()) { | ||
window_.webContents.reloadIgnoringCache(); | ||
} | ||
@@ -80,0 +84,0 @@ } |
{ | ||
"name": "electron-reloader", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Simple auto-reloading for Electron apps during development", | ||
@@ -39,8 +39,10 @@ "license": "MIT", | ||
"dependencies": { | ||
"chokidar": "^2.0.0", | ||
"electron-is-dev": "^0.3.0" | ||
"chalk": "^2.4.2", | ||
"chokidar": "^3.0.0", | ||
"date-time": "^3.1.0", | ||
"electron-is-dev": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"electron": "^1.7.10", | ||
"xo": "*" | ||
"electron": "^5.0.1", | ||
"xo": "^0.24.0" | ||
}, | ||
@@ -47,0 +49,0 @@ "xo": { |
@@ -16,3 +16,5 @@ # electron-reloader [![Build Status](https://travis-ci.org/sindresorhus/electron-reloader.svg?branch=master)](https://travis-ci.org/sindresorhus/electron-reloader) | ||
*Requires Electron 5 or later.* | ||
## Usage | ||
@@ -25,3 +27,3 @@ | ||
require('electron-reloader')(module); | ||
} catch (err) {} | ||
} catch (_) {} | ||
``` | ||
@@ -40,3 +42,3 @@ | ||
Type: `Object` | ||
Type: `object` | ||
@@ -47,3 +49,3 @@ The global `module` object. | ||
Type: `Object` | ||
Type: `object` | ||
@@ -59,3 +61,3 @@ ##### debug | ||
Type: `Array<string|RegExp>` | ||
Type: `Array<string | RegExp>` | ||
@@ -88,2 +90,3 @@ Ignore patterns passed to [`chokidar`](https://github.com/paulmillr/chokidar#path-filtering). By default, files/directories starting with a `.`, `.map` files, and `node_modules` directories are ignored. This option is additive to those. | ||
- [electron-unhandled](https://github.com/sindresorhus/electron-unhandled) - Catch unhandled errors and promise rejections in your Electron app | ||
- [electron-serve](https://github.com/sindresorhus/electron-serve) - Static file serving for Electron apps | ||
@@ -90,0 +93,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6908
67
91
4
+ Addedchalk@^2.4.2
+ Addeddate-time@^3.1.0
+ Addedansi-styles@3.2.1(transitive)
+ Addedanymatch@3.1.3(transitive)
+ Addedbinary-extensions@2.3.0(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedchokidar@3.6.0(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addeddate-time@3.1.0(transitive)
+ Addedelectron-is-dev@1.2.0(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfsevents@2.3.3(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedis-binary-path@2.1.0(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedreaddirp@3.6.0(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedtime-zone@1.0.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)
- Removedanymatch@2.0.0(transitive)
- Removedarr-diff@4.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@3.1.0(transitive)
- Removedarray-unique@0.3.2(transitive)
- Removedassign-symbols@1.0.0(transitive)
- Removedasync-each@1.0.6(transitive)
- Removedatob@2.1.2(transitive)
- Removedbase@0.11.2(transitive)
- Removedbinary-extensions@1.13.1(transitive)
- Removedbindings@1.5.0(transitive)
- Removedbraces@2.3.2(transitive)
- Removedcache-base@1.0.1(transitive)
- Removedchokidar@2.1.8(transitive)
- Removedclass-utils@0.3.6(transitive)
- Removedcollection-visit@1.0.0(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedcopy-descriptor@0.1.1(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddefine-property@0.2.51.0.02.0.2(transitive)
- Removedelectron-is-dev@0.3.0(transitive)
- Removedexpand-brackets@2.1.4(transitive)
- Removedextend-shallow@2.0.13.0.2(transitive)
- Removedextglob@2.0.4(transitive)
- Removedfile-uri-to-path@1.0.0(transitive)
- Removedfill-range@4.0.0(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfragment-cache@0.2.1(transitive)
- Removedfsevents@1.2.13(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-value@2.0.6(transitive)
- Removedglob-parent@3.1.0(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhas-value@0.3.11.0.0(transitive)
- Removedhas-values@0.1.41.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-accessor-descriptor@1.0.1(transitive)
- Removedis-binary-path@1.0.1(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-data-descriptor@1.0.1(transitive)
- Removedis-descriptor@0.1.71.0.3(transitive)
- Removedis-extendable@0.1.11.0.1(transitive)
- Removedis-glob@3.1.0(transitive)
- Removedis-number@3.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisobject@2.1.03.0.1(transitive)
- Removedkind-of@3.2.24.0.06.0.3(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmap-visit@1.0.0(transitive)
- Removedmicromatch@3.1.10(transitive)
- Removedmixin-deep@1.3.2(transitive)
- Removedms@2.0.0(transitive)
- Removednan@2.20.0(transitive)
- Removednanomatch@1.2.13(transitive)
- Removednormalize-path@2.1.1(transitive)
- Removedobject-copy@0.1.0(transitive)
- Removedobject-visit@1.0.1(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedpascalcase@0.1.1(transitive)
- Removedpath-dirname@1.0.2(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedposix-character-classes@0.1.1(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedreaddirp@2.2.1(transitive)
- Removedregex-not@1.0.2(transitive)
- Removedremove-trailing-separator@1.1.0(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedresolve-url@0.2.1(transitive)
- Removedret@0.1.15(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedsafe-regex@1.1.0(transitive)
- Removedset-value@2.0.1(transitive)
- Removedsnapdragon@0.8.2(transitive)
- Removedsnapdragon-node@2.1.1(transitive)
- Removedsnapdragon-util@3.0.1(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedsource-map-resolve@0.5.3(transitive)
- Removedsource-map-url@0.4.1(transitive)
- Removedsplit-string@3.1.0(transitive)
- Removedstatic-extend@0.1.2(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedto-object-path@0.3.0(transitive)
- Removedto-regex@3.0.2(transitive)
- Removedto-regex-range@2.1.1(transitive)
- Removedunion-value@1.0.1(transitive)
- Removedunset-value@1.0.0(transitive)
- Removedupath@1.2.0(transitive)
- Removedurix@0.1.0(transitive)
- Removeduse@3.1.1(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updatedchokidar@^3.0.0
Updatedelectron-is-dev@^1.1.0