generated from sindresorhus/electron-boilerplate
-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74eb0e5
commit 8fe4746
Showing
39 changed files
with
2,932 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* eslint unicorn/prefer-module: 0 */ | ||
// App entry | ||
const main = require( './src/main.js' ) | ||
const main = require( './src/index.js' ) | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
const config = require( './config.js' ) | ||
const EXIT_CODES = require( './exit-codes.js' ) | ||
const keycode = require( './keycode.js' ) | ||
const utils = require( './utils.js' ) | ||
|
||
module.exports = { config, EXIT_CODES } | ||
module.exports = { config, EXIT_CODES, keycode, utils } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* eslint unicorn/prefer-module: 0 */ | ||
|
||
/* Utilities */ | ||
const debounce = ( func, delay ) => { | ||
|
||
let debounceTimer | ||
|
||
return function ( ...args ) { | ||
|
||
clearTimeout( debounceTimer ) | ||
|
||
// Pass { abort: true } to cancel | ||
if ( args[0] && args[0].abort ) { | ||
|
||
return | ||
|
||
} | ||
|
||
debounceTimer = setTimeout( () => func.apply( this, args ), delay ) | ||
|
||
} | ||
|
||
} | ||
|
||
const checkboxTrue = ( value, key ) => | ||
// Console.log(value, key, typeof value === 'object', value.includes( key )) | ||
( typeof value === 'object' && value.includes( key ) ) | ||
|
||
/* eslint-disable no-prototype-builtins */ | ||
/** | ||
* Recursively Object.freeze() on objects and functions | ||
* @see https://github.com/substack/deep-freeze | ||
* @param o Object on which to lock the attributes | ||
*/ | ||
const deepFreeze = o => { | ||
|
||
Object.freeze( o ) | ||
|
||
for ( const prop of Object.getOwnPropertyNames( o ) ) { | ||
|
||
if ( o.hasOwnProperty( prop ) | ||
&& o[prop] !== null | ||
&& ( typeof o[prop] === 'object' || typeof o[prop] === 'function' ) | ||
&& !Object.isFrozen( o[prop] ) ) { | ||
|
||
deepFreeze( o[prop] ) | ||
|
||
} | ||
|
||
} | ||
|
||
return o | ||
|
||
} | ||
|
||
/** | ||
* Check for libappindicator1 support before creating tray icon | ||
*/ | ||
const checkLinuxTraySupport = cb => { | ||
|
||
const cp = require( 'child_process' ) | ||
|
||
// Check that we're on Ubuntu (or another debian system) and that we have | ||
// libappindicator1. If WebTorrent was installed from the deb file, we should | ||
// always have it. If it was installed from the zip file, we might not. | ||
cp.exec( 'dpkg --get-selections libappindicator1', ( error, stdout ) => { | ||
|
||
if ( error ) { | ||
|
||
return cb( false ) | ||
|
||
} | ||
|
||
// Unfortunately there's no cleaner way, as far as I can tell, to check | ||
// whether a debian package is installed: | ||
cb( stdout.endsWith( '\tinstall\n' ) ) | ||
|
||
} ) | ||
|
||
} | ||
|
||
/* eslint-enable */ | ||
|
||
module.exports = { | ||
checkboxTrue, | ||
checkLinuxTraySupport, | ||
debounce, | ||
deepFreeze, | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const main = require( './main.js' ) | ||
|
||
module.exports = main |
Oops, something went wrong.