mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-29 07:34:07 +00:00
* feat: update "Show in Folder" label based on platform in ManageWorkspace, Collection, CollectionItem, and WorkspaceHome components * refactor: remove duplicate "Rename" item push in CollectionItem component
60 lines
1.5 KiB
JavaScript
60 lines
1.5 KiB
JavaScript
import trim from 'lodash/trim';
|
|
import platform from 'platform';
|
|
import path from './path';
|
|
|
|
export const isElectron = () => {
|
|
if (!window) {
|
|
return false;
|
|
}
|
|
|
|
return window.ipcRenderer ? true : false;
|
|
};
|
|
|
|
export const resolveRequestFilename = (name, extension = 'bru') => {
|
|
return `${trim(name)}.${extension}`;
|
|
};
|
|
|
|
export const getSubdirectoriesFromRoot = (rootPath, pathname) => {
|
|
const relativePath = path.relative(rootPath, pathname);
|
|
return relativePath ? relativePath.split(path.sep) : [];
|
|
};
|
|
|
|
export const isWindowsOS = () => {
|
|
const os = platform.os;
|
|
const osFamily = os.family.toLowerCase();
|
|
|
|
return osFamily.includes('windows');
|
|
};
|
|
|
|
export const isMacOS = () => {
|
|
const os = platform.os;
|
|
const osFamily = os.family.toLowerCase();
|
|
|
|
return osFamily.includes('os x');
|
|
};
|
|
|
|
export const isLinuxOS = () => {
|
|
const os = platform.os;
|
|
const osFamily = os.family.toLowerCase();
|
|
|
|
return osFamily.includes('linux') || osFamily.includes('ubuntu') || osFamily.includes('debian') || osFamily.includes('fedora') || osFamily.includes('centos') || osFamily.includes('arch');
|
|
};
|
|
|
|
export const getRevealInFolderLabel = () => {
|
|
if (isMacOS()) return 'Reveal in Finder';
|
|
if (isWindowsOS()) return 'Reveal in File Explorer';
|
|
return 'Reveal in File Manager';
|
|
};
|
|
|
|
export const getAppInstallDate = () => {
|
|
let dateString = localStorage.getItem('bruno.installedOn');
|
|
|
|
if (!dateString) {
|
|
dateString = new Date().toISOString();
|
|
localStorage.setItem('bruno.installedOn', dateString);
|
|
}
|
|
|
|
const date = new Date(dateString);
|
|
return date;
|
|
};
|