Skip to content

Commit

Permalink
fix: resolve relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
mortada-codes committed Jan 28, 2022
1 parent 92ec9db commit da7b185
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {useDebounce} from 'react-use';

import 'antd/dist/antd.less';

import path from 'path';
import styled from 'styled-components';

import {DEFAULT_KUBECONFIG_DEBOUNCE, ROOT_FILE_ENTRY} from '@constants/constants';
Expand Down Expand Up @@ -75,12 +76,13 @@ const App = () => {

const onExecutedFrom = useCallback(
(_, data) => {
if (data.path) {
const selectedProject: Project | undefined | null = projects.find(p => p.rootFolder === data.path);
const targetPath = path.resolve(data.path);
if (targetPath) {
const selectedProject: Project | undefined | null = projects.find(p => p.rootFolder === targetPath);
if (selectedProject && getFileStats(selectedProject.rootFolder)?.isDirectory()) {
dispatch(setOpenProject(selectedProject.rootFolder));
} else {
dispatch(setCreateProject({rootFolder: data.path}));
dispatch(setCreateProject({rootFolder: targetPath}));
}
dispatch(setLoadingProject(false));
return;
Expand Down

0 comments on commit da7b185

Please sign in to comment.