Skip to content
This repository was archived by the owner on May 24, 2022. It is now read-only.
Prev Previous commit
Next Next commit
Fix lint in electron
  • Loading branch information
amaury1093 committed Nov 22, 2018
commit 45e06efb00fbe2ae60caae2890f53ac563efcf8b
8 changes: 5 additions & 3 deletions packages/electron/src/getParityPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const fsStat = promisify(stat);
* The default path to install parity, in case there's no other instance found
* on the machine.
*/
export function defaultParityPath() {
export function defaultParityPath () {
return Promise.resolve(
`${app.getPath('userData')}/parity${
process.platform === 'win32' ? '.exe' : ''
Expand All @@ -33,7 +33,7 @@ export function defaultParityPath() {
*
* @ignore
*/
let parityPath: string;
let parityPath: string | undefined;

/**
* Test if `parity` command is in $PATH.
Expand All @@ -45,6 +45,8 @@ const isParityInPath = async () => {
if (parityCommandExists) {
// If yes, return `parity` as command to launch parity
return 'parity';
} else {
throw new Error('Parity not in path.');
}
};

Expand Down Expand Up @@ -101,7 +103,7 @@ const doesParityExist = () =>
/**
* Returns the path to Parity, or throws if parity is not found.
*/
export async function getParityPath() {
export async function getParityPath () {
if (parityPath) {
return parityPath;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/electron/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface ParityElectronOptions {
* Set default options for @parity/electron. Can be skipped if we don't want to
* override default options.
*/
function parityElectron(options: ParityElectronOptions = { logger: debug }) {
function parityElectron (options: ParityElectronOptions = { logger: debug }) {
if (options.logger) {
setLogger(options.logger);
}
Expand Down
14 changes: 8 additions & 6 deletions packages/electron/src/isParityRunning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface IsParityRunningOptions {
* Detect if another instance of parity is already running or not. To achieve
* that, we just ping on the common hosts.
*/
export async function isParityRunning(
export async function isParityRunning (
options: IsParityRunningOptions = {
wsInterface: '127.0.0.1',
wsPort: '8546'
Expand All @@ -43,15 +43,17 @@ export async function isParityRunning(
setTimeout(() => resolve(false), TIMEOUT_MS);

hostsToPing.map(host =>
axios.get(host)
axios
.get(host)
.then(_ => {
logger()('@parity/electron:main')(
`Another instance of parity is already running on ${host}, skip running local instance.`
);
resolve(true)
resolve(true);
})
.catch(() => {
return null;
})
.catch(() => { return null; })
);

})
});
}
9 changes: 4 additions & 5 deletions packages/electron/src/runParity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const fsChmod = promisify(chmod);
/**
* @ignore
*/
let parity: ChildProcess = null; // Will hold the running parity instance
let parity: ChildProcess | null = null; // Will hold the running parity instance

/**
* These are errors output by parity, which we should ignore (i.e. don't
Expand All @@ -41,7 +41,7 @@ const catchableErrors = [
/**
* Spawns a child process to run Parity.
*/
export async function runParity(
export async function runParity (
options: RunParityOptions = {
flags: [],
onParityError: () => {
Expand All @@ -68,7 +68,6 @@ export async function runParity(
}

return new Promise((resolve, reject) => {

let logLastLine = ''; // Always contains last line of the Parity logs

// Run an instance of parity with the correct flags
Expand Down Expand Up @@ -119,15 +118,15 @@ export async function runParity(
// Otherwise, if the exit code is not 0, then we show some error message
onParityError(new Error(`Exit code ${exitCode}, with signal ${signal}.`));
});
})
});
}

/**
* If a Parity process has been spawned with runParity, then it kills this
* process. However, there's no guarantee that Parity has been cleanly killed,
* and the Promise resolves instantly.
*/
export function killParity() {
export function killParity () {
if (parity) {
logger()('Stopping parity.');
parity.kill();
Expand Down
2 changes: 1 addition & 1 deletion packages/electron/src/signerNewToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import logger from './utils/logger';
* Runs parity signer new-token and resolves with a new secure token to be
* used in a dapp. Rejects if no token could be extracted.
*/
export function signerNewToken(): Promise<string> {
export function signerNewToken (): Promise<string> {
return new Promise(async (resolve, reject) => {
logger()('@parity/electron:main')('Requesting new token.');

Expand Down