How to use the electron.app.getPath function in electron

To help you get started, we’ve selected a few electron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GNS3 / gns3-web-ui / console-executor.js View on Github external
async function setPATHEnv() {
  const puttyLookup = [
    path.join(__dirname, 'dist', 'putty'),
    path.join(path.dirname(app.getPath('exe')), 'dist', 'putty')
  ];

  // prevent adding duplicates
  let extra = [
    ...puttyLookup,
  ].filter((dir) => {
    return process.env.PATH.indexOf(dir) < 0;
  });
  extra.push(process.env.PATH);
  process.env.PATH = extra.join(";");
}
github josephpei / uv2ray / src / main / bootstrap.js View on Github external
* Set `__static` path to static files in production
 * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html
 */
if (process.env.NODE_ENV !== 'development') {
  global.__static = require('path')
    .join(__dirname, '/static')
    .replace(/\\/g, '\\\\')
}

// 未捕获的rejections
process.on('unhandledRejection', (reason, p) => {
  logger.error(`Unhandled Rejection at: Promise ${p}, reason: ${reason}`)
})

// 应用配置存储目录
export const appConfigDir = app.getPath('userData')
// 应用配置存储路径
export const appConfigPath = path.join(appConfigDir, 'gui-config.json')
// 默认的v2ray下载目录
export const defaultV2rayDownloadDir = path.join(appConfigDir, 'v2ray')
// pac文件下载目录
export const pacPath = path.join(appConfigDir, 'pac.txt')
// 记录上次订阅更新时间的文件
export const subscribeUpdateFile = path.join(appConfigDir, '.subscribe.update.last')
// 当前可执行程序的路径
export const exePath = app.getPath('exe')
// windows sysproxy.exe文件的路径
let _winToolPath
if (isWin) {
  if (process.env.NODE_ENV === 'development') {
    _winToolPath = path.resolve(__dirname, '../tools/sysproxy.exe')
  } else {
github PACKED-vzw / CultURIze / src / main.ts View on Github external
function writeToken(token: string) {
    const path = app.getPath("userData") + "/culturize.json";
    console.log(path);
    const settings = {"github-key": token};
    fs.writeFileSync(path, JSON.stringify(settings));
}
github steelbrain / denode / browser / main.js View on Github external
const Path = require('path')
const { app, ipcMain, BrowserWindow } = require('electron')
const Helpers = require('./helpers')

require('electron-debug')({ showDevTools: true })
require('electron-context-menu')()

const options = Helpers.getElectronOptions()
const denodeOptions = Helpers.getDenodeOptions(options.manifest)

if (denodeOptions.DENODE_INSECURE) {
  app.commandLine.appendSwitch('--ignore-certificate-errors')
}

app.setName('denode')
app.setPath('userData', Path.join(Path.dirname(app.getPath('userData')), 'denode'))
app.setPath('userCache', Path.join(Path.dirname(app.getPath('userCache')), 'denode'))

app.on('window-all-closed', function() {
  app.quit()
})
app.on('ready', Helpers.installExtensions(function() {
  const electronOptions = Object.assign({}, options.electron)
  if (electronOptions.hide) {
    Object.assign(electronOptions, {
      height: 400,
    })
  }

  const window = new BrowserWindow(electronOptions)
  window.loadURL(`file://${Path.normalize(Path.join(__dirname, '..', 'renderer', 'index.html'))}`)
  window.webContents.openDevTools({ mode: 'bottom' })
github xiaozhikang0916 / kcmodmanager / main.js View on Github external
const { app, BrowserWindow, Menu, ipcMain } = require('electron')
const path = require('path')
const Config = require('./scripts/config')

let win
let setting
let config = new Config(path.join(app.getPath('appData'), 'kcmodmanager'))

function createWindow() {
    win = new BrowserWindow({ width: 1200, height: 600 })
    win.loadFile('index.html')
    buildMenu()
    win.on('closed', () => {
        if (setting) {
            setting.close()
            setting = null
        }
        win = null
    })

}

function buildMenu() {
github AnalyzeOrFeed / aof-replay-client / src / index.js View on Github external
function getStaticData(callback) {
	logger.info("Loading static data");
	fs.readFile(app.getPath("userCache") + "/static", function(err, data) {
		if (!err) {
			logger.info("Reading static data from local cache");
			staticData = JSON.parse(data);
		}

		logger.info("Retrieving static data from server");
		request({ url: "https://api.aof.gg/v2/data/static", json: true, timeout: 10000}, function(err, response, body) {
			if (err || !response || response.statusCode != 200) {
				logger.warn("Error while retrieving static data: " + err + " " + JSON.stringify(response));
				return;
			}
			staticData.regions = body.regions;
			staticData.leagues = body.leagues;
			fs.writeFileSync(app.getPath("userCache") + "/static", JSON.stringify(staticData));

			ddragonVersion = body.newestVersion.riotVersion + "/";
github stream-labs / streamlabs-obs / main.js View on Github external
app.on('ready', () => {
    if (
      !process.argv.includes('--skip-update') &&
      ((process.env.NODE_ENV === 'production') || process.env.SLOBS_FORCE_AUTO_UPDATE)) {
      const updateInfo = {
        baseUrl: 'https://slobs-cdn.streamlabs.com',
        version: pjson.version,
        exec: process.argv,
        cwd: process.cwd(),
        waitPids: [ process.pid ],
        appDir: path.dirname(app.getPath('exe')),
        tempDir: path.join(app.getPath('temp'), 'slobs-updater'),
        cacheDir: app.getPath('userData'),
        versionFileName: `${releaseChannel}.json`
      };

      bootstrap(updateInfo, startApp, app.exit);
    } else {
      startApp();
    }
  });
github zeebe-io / zeebe-modeler / app / lib / index.js View on Github external
function bootstrap() {
  const appPath = path.dirname(app.getPath('exe')),
        cwd = process.cwd(),
        userDesktopPath = app.getPath('userDesktop'),
        userPath = app.getPath('userData');

  const {
    files,
    flags: flagOverrides
  } = Cli.parse(process.argv, cwd);

  let resourcesPaths = [
    path.join(appPath, 'resources'),
    path.join(userPath, 'resources')
  ];

  if (process.env.NODE_ENV === 'development') {
    resourcesPaths = [
      ...resourcesPaths,
      path.join(cwd, 'resources')
    ];
github gaccettola / mortis / client_desktop / source / app / app_info / app_info.js View on Github external
function apppath_info_read ( )
        {
            listof_info_add ( 'Home',       app.getPath ( 'home' )      );

            listof_info_add ( 'Data',       app.getPath ( 'appData' )   );

            listof_info_add ( 'User',       app.getPath ( 'userData' )  );

            listof_info_add ( 'Temp',       app.getPath ( 'temp' )      );
        }
github jupyterlab / jupyterlab_app / src / main / server.ts View on Github external
this._startServer = new Promise((resolve, reject) => {
            let urlRegExp = /http:\/\/localhost:\d+\/\S*/g;
            let tokenRegExp = /token=\w+/g;
            let baseRegExp = /http:\/\/localhost:\d+\//g;
            let home = app.getPath('home');

            this._nbServer = execFile(this._info.environment.path, ['-m', 'jupyter', 'notebook', '--no-browser'], { cwd: home });

            this._nbServer.on('exit', () => {
                this._serverStartFailed();
                reject(new Error('Could not find Jupyter in PATH'));
            });

            this._nbServer.on('error', (err: Error) => {
                this._serverStartFailed();
                reject(new Error('Could not find Jupyter in PATH'));
            });

            this._nbServer.stderr.on('data', (serverBuff: string) => {
                let urlMatch = serverBuff.toString().match(urlRegExp);
                if (!urlMatch) {