Fixed PATH env variable for production bundle

Summary:
In my last plugin for React VR I used spawn heavily to call adb and python2. It worked out well, but after Flipper released, I noticed that all my spawn commands were broken.

I found that Electron start in different way when bundled as production bundle, and because of it, it does not inherit process.env.PATH in a same way as it do this for development mode. (only linux/mac issue)

In this diff I used npm package which detects linux/mac and executes bash command which returns all the env variables from the system. After it, it takes PATH and merge it with process.env.PATH.

Reviewed By: passy

Differential Revision: D16457847

fbshipit-source-id: 60226f2d7977f1dfec49de6e889f3115d8688991
This commit is contained in:
Arthur Kushka
2019-07-24 06:01:20 -07:00
committed by Facebook Github Bot
parent df55ac263d
commit d2f9697deb
3 changed files with 76 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ const {app, BrowserWindow, ipcMain, Notification} = require('electron');
const path = require('path');
const url = require('url');
const fs = require('fs');
const fixPath = require('fix-path');
const {exec} = require('child_process');
const compilePlugins = require('./compilePlugins.js');
const setup = require('./setup');
@@ -19,6 +20,9 @@ const delegateToLauncher = require('./launcher');
const expandTilde = require('expand-tilde');
const yargs = require('yargs');
// Adds system PATH folders to process.env.PATH for MacOS production bundles.
fixPath();
// disable electron security warnings: https://github.com/electron/electron/blob/master/docs/tutorial/security.md#security-native-capabilities-and-your-responsibility
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = true;