mirror of
https://github.com/usebruno/bruno.git
synced 2025-01-01 19:49:41 +01:00
36 lines
821 B
JavaScript
36 lines
821 B
JavaScript
import trim from 'lodash/trim';
|
|
import path from 'path';
|
|
import slash from './slash';
|
|
|
|
export const isElectron = () => {
|
|
if (!window) {
|
|
return false;
|
|
}
|
|
|
|
return window.ipcRenderer ? true : false;
|
|
};
|
|
|
|
export const isLocalCollection = (collection) => {
|
|
return collection.pathname ? true : false;
|
|
};
|
|
|
|
export const resolveRequestFilename = (name) => {
|
|
return `${trim(name)}.bru`;
|
|
};
|
|
|
|
export const getSubdirectoriesFromRoot = (rootPath, pathname) => {
|
|
// convert to unix style path
|
|
pathname = slash(pathname);
|
|
rootPath = slash(rootPath);
|
|
|
|
const relativePath = path.relative(rootPath, pathname);
|
|
return relativePath ? relativePath.split(path.sep) : [];
|
|
};
|
|
|
|
export const getDirectoryName = (pathname) => {
|
|
// convert to unix style path
|
|
pathname = slash(pathname);
|
|
|
|
return path.dirname(pathname);
|
|
}
|