项目作者: ganeshrvel

项目描述 :
Get the root path of an Electron Application
高级语言: JavaScript
项目地址: git://github.com/ganeshrvel/npm-electron-root-path.git
创建时间: 2019-01-20T06:15:46Z
项目社区:https://github.com/ganeshrvel/npm-electron-root-path

开源协议:MIT License

下载


npm: electron-root-path

Introduction

Get the root path of an Electron Application.

Finding the root path of an electron app can be tricky, this npm package solves this issue. Follow further instructions to implement the same inside your app.

Initially, I’d created electron-root-path package for OpenMTP - Advanced Android File Transfer Application for macOS. It works fine with Electron React Redux Advanced Boilerplate and electron-react-boilerplate

Installation

  1. $ npm install electron-root-path
  2. or
  3. $ yarn add electron-root-path

Usage

  1. // Import ES6 way
  2. import { rootPath } from 'electron-root-path';
  3. // Import ES5 way
  4. const rootPath = require('electron-root-path').rootPath;
  5. // e.g:
  6. // read a file in the root
  7. const location = path.join(rootPath, 'package.json');
  8. const pkgInfo = fs.readFileSync(location, { encoding: 'utf8' });
  • After packaging the app, the rootPath will point to the absolute directory path of .app
  1. // eg: /Applications/AppName.app
  • Handle the packaged condition if required using:
  1. const isProd = process.env.NODE_ENV === 'production';
  2. // or
  3. // npm install electron-is-packaged
  4. const isPackaged = require('electron-is-packaged').isPackaged;

Building from Source

Requirements: Node.js v6+, Git and npm

Clone

  1. $ git clone --depth 1 --single-branch --branch master https://github.com/ganeshrvel/npm-electron-root-path.git
  2. $ cd npm-electron-root-path

Contribute

  • Fork the repo and create your branch from master.
  • Ensure that the changes pass linting.
  • Update the documentation if needed.
  • Make sure your code lints.
  • Issue a pull request!

When you submit code changes, your submissions are understood to be under the same MIT License that covers the project. Feel free to contact the maintainers if that’s a concern.

Buy me a coffee

Help me keep the app FREE and open for all.
Paypal me: paypal.me/ganeshrvel

Contacts

Please feel free to contact me at ganeshrvel@outlook.com

More repos

License

electron-root-path | Get the root path of an Electron Application is released under MIT License.

Copyright © 2018-Present Ganesh Rathinavel