Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use standard linter locally #62

Merged
merged 4 commits into from
Aug 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
language: node_js

node_js:
- "6"
- "node"
- "lts/*"

install: npm install

before_script:
- npm install -g standard

script:
- standard
- npm run lint
18 changes: 9 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const createHardresetHandler = (eXecutable, hardResetMethod, argv) =>
() => {
// Detaching child is useful when in Windows to let child
// live after the parent is killed
let args = (argv || []).concat([appPath])
let child = spawn(eXecutable, args, {
const args = (argv || []).concat([appPath])
const child = spawn(eXecutable, args, {
detached: true,
stdio: 'inherit'
})
Expand All @@ -41,23 +41,23 @@ const createHardresetHandler = (eXecutable, hardResetMethod, argv) =>
}

module.exports = (glob, options = {}) => {
let browserWindows = []
let watcher = chokidar.watch(glob, Object.assign({ ignored: [ignoredPaths, mainFile] }, options))
const browserWindows = []
const watcher = chokidar.watch(glob, Object.assign({ ignored: [ignoredPaths, mainFile] }, options))

// Callback function to be executed:
// I) soft reset: reload browser windows
let softResetHandler = () => browserWindows.forEach(bw => bw.webContents.reloadIgnoringCache())
const softResetHandler = () => browserWindows.forEach(bw => bw.webContents.reloadIgnoringCache())
// II) hard reset: restart the whole electron process
let eXecutable = options.electron
let hardResetHandler = createHardresetHandler(eXecutable, options.hardResetMethod, options.argv)
const eXecutable = options.electron
const hardResetHandler = createHardresetHandler(eXecutable, options.hardResetMethod, options.argv)

// Add each created BrowserWindow to list of maintained items
app.on('browser-window-created', (e, bw) => {
browserWindows.push(bw)

// Remove closed windows from list of maintained items
bw.on('closed', function () {
let i = browserWindows.indexOf(bw) // Must use current index
const i = browserWindows.indexOf(bw) // Must use current index
browserWindows.splice(i, 1)
})
})
Expand All @@ -68,7 +68,7 @@ module.exports = (glob, options = {}) => {
// Preparing hard reset if electron executable is given in options
// A hard reset is only done when the main file has changed
if (eXecutable && fs.existsSync(eXecutable)) {
let hardWatcher = chokidar.watch(mainFile, Object.assign({ ignored: [ignoredPaths] }, options))
const hardWatcher = chokidar.watch(mainFile, Object.assign({ ignored: [ignoredPaths] }, options))

if (options.forceHardReset === true) {
// Watch every file for hard reset and not only the main file
Expand Down
Loading