Files
flipper/desktop/app/src/utils/pathUtils.tsx
Anna Murawska 5e979403a0 Show FB-internal announcements only in internal changelog (#1544)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/1544

Added Facebook changelog file

Reviewed By: nikoant

Differential Revision: D23930322

fbshipit-source-id: bb6be359d36188f142d342604e50010170086610
2020-09-28 02:42:00 -07:00

53 lines
1.2 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;
}
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;
}