paths.js 1.02 KiB
Newer Older
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
Amaury Martiny's avatar
Amaury Martiny committed
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause

import electron from 'electron';
import path from 'path';

const { app } = electron;
const IS_TEST = !app;
const IS_PACKAGED = !IS_TEST && app.isPackaged;
Amaury Martiny's avatar
Amaury Martiny committed

const BUNDLED_IPC_PATH =
  process.platform === 'win32'
    ? path.join(
      '\\\\?\\pipe',
      electron.app.getPath('userData'),
      'fether-parity-ipc.ipc'
    )
    : path.join(electron.app.getPath('userData'), 'fether-parity-ipc.ipc');

Amaury Martiny's avatar
Amaury Martiny committed
/**
 * Get the path to the `static` folder.
 *
 * @see https://github.com/electron-userland/electron-webpack/issues/52
 */
const staticPath = IS_PACKAGED
Amaury Martiny's avatar
Amaury Martiny committed
  ? __dirname.replace(/app\.asar$/, 'static')
  : path.join(process.cwd(), 'static');
Amaury Martiny's avatar
Amaury Martiny committed

/**
 * Get the path to the bundled Parity Ethereum binary.
 */
const bundledParityPath =
  process.platform === 'win32'
    ? path.join(staticPath, 'parity.exe')
    : path.join(staticPath, 'parity');

export { IS_PACKAGED, BUNDLED_IPC_PATH, bundledParityPath, staticPath };