Files
flipper/desktop/app/src/utils/pathUtils.tsx
Pascal Hartig 2ae7d13a64 Strip application path from stack traces
Summary:
Stacktraces right now always contain the `/home/$USER/.cache/flipper-launcher/v1.2.3/...` (or equivalent)
which makes deduping and reading harder. This strips the paths.

Reviewed By: mweststrate

Differential Revision: D27130251

fbshipit-source-id: c0e8d5eb1575c6269d49a6aee0e8a5e93996d223
2021-03-19 07:31:34 -07:00

62 lines
1.4 KiB
TypeScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import path from 'path';
import fs from 'fs';
import {remote} from 'electron';
import config from '../fb-stubs/config';
let _staticPath = '';
export function getStaticPath() {
if (_staticPath) {
return _staticPath;
}
_staticPath = path.resolve(__dirname, '..', '..', '..', 'static');
if (fs.existsSync(_staticPath)) {
return _staticPath;
}
if (remote && fs.existsSync(remote.app.getAppPath())) {
_staticPath = path.join(remote.app.getAppPath());
}
if (!fs.existsSync(_staticPath)) {
throw new Error('Static path does not exist: ' + _staticPath);
}
return _staticPath;
}
let _appPath: string | undefined = undefined;
export function getAppPath() {
if (!_appPath) {
_appPath = path.join(getStaticPath(), '..');
}
return _appPath;
}
export function getChangelogPath() {
const staticPath = getStaticPath();
let changelogPath = '';
if (config.isFBBuild) {
changelogPath = path.resolve(staticPath, 'facebook');
} else {
changelogPath = staticPath;
}
if (fs.existsSync(changelogPath)) {
return changelogPath;
}
if (!fs.existsSync(changelogPath)) {
throw new Error('Changelog path path does not exist: ' + changelogPath);
}
return changelogPath;
}