Replace ad-hoc home dir expansion with package
Summary: Instead of replacing the tilde with home-dirs on an incomplete, ad-hoc basis, let's use a package for this. It also supports `~USER` resolution which someone might reasonbly expect to work if `~/DIR` is working. Reviewed By: jknoxville Differential Revision: D13940956 fbshipit-source-id: 5bfa9b8b2540fed8c05c856ff736e48e925f985d
This commit is contained in:
committed by
Facebook Github Bot
parent
ce80e03e8f
commit
dc412ce0bc
@@ -9,8 +9,9 @@ import {Button, ButtonGroup, Component} from 'flipper';
|
||||
import {connect} from 'react-redux';
|
||||
import AndroidDevice from '../devices/AndroidDevice';
|
||||
import IOSDevice from '../devices/IOSDevice';
|
||||
import os from 'os';
|
||||
import expandTilde from 'expand-tilde';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import adb from 'adbkit-fb';
|
||||
import {exec, spawn} from 'child_process';
|
||||
import {remote} from 'electron';
|
||||
@@ -19,11 +20,9 @@ import {reportPlatformFailures} from '../utils/metrics';
|
||||
|
||||
let CAPTURE_LOCATION = remote.app.getPath('desktop');
|
||||
try {
|
||||
CAPTURE_LOCATION =
|
||||
JSON.parse(window.process.env.CONFIG).screenCapturePath.replace(
|
||||
/^~/,
|
||||
os.homedir(),
|
||||
) || CAPTURE_LOCATION;
|
||||
CAPTURE_LOCATION = expandTilde(
|
||||
JSON.parse(window.process.env.CONFIG).screenCapturePath || CAPTURE_LOCATION,
|
||||
);
|
||||
} catch (e) {}
|
||||
|
||||
import type BaseDevice from '../devices/BaseDevice';
|
||||
|
||||
@@ -11,6 +11,7 @@ const fs = require('fs');
|
||||
const Metro = require('metro');
|
||||
const util = require('util');
|
||||
const recursiveReaddir = require('recursive-readdir');
|
||||
const expandTilde = require('expand-tilde');
|
||||
const HOME_DIR = require('os').homedir();
|
||||
|
||||
/* eslint-disable prettier/prettier */
|
||||
@@ -115,7 +116,7 @@ function pluginEntryPoints(additionalPaths = []) {
|
||||
return entryPoints;
|
||||
}
|
||||
function entryPointForPluginFolder(pluginPath) {
|
||||
pluginPath = pluginPath.replace('~', HOME_DIR);
|
||||
pluginPath = expandTilde(pluginPath);
|
||||
if (!fs.existsSync(pluginPath)) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ const {exec} = require('child_process');
|
||||
const compilePlugins = require('./compilePlugins.js');
|
||||
const os = require('os');
|
||||
const setup = require('./setup');
|
||||
const expandTilde = require('expand-tilde');
|
||||
|
||||
// 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;
|
||||
@@ -42,7 +43,7 @@ const pluginPaths = config.pluginPaths
|
||||
path.join(__dirname, '..', 'src', 'plugins'),
|
||||
path.join(__dirname, '..', 'src', 'fb', 'plugins'),
|
||||
)
|
||||
.map(p => p.replace(/^~/, os.homedir()))
|
||||
.map(expandTilde)
|
||||
.filter(fs.existsSync);
|
||||
|
||||
process.env.CONFIG = JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user