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:
Pascal Hartig
2019-02-04 04:39:31 -08:00
committed by Facebook Github Bot
parent ce80e03e8f
commit dc412ce0bc
3 changed files with 9 additions and 8 deletions

View File

@@ -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';