Skip to content

Commit

Permalink
fix: make custom items path prettier (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
cazala authored Jan 7, 2025
1 parent 72ff756 commit 75274a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions packages/renderer/src/modules/rpc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ interface Callbacks {
) => Promise<Result[Method.WRITE_FILE]>;
}

const getPath = async (path: string, project: Project) => {
const getPath = async (filePath: string, project: Project) => {
let basePath = project.path;
if (path === 'custom' || path.startsWith('custom/')) {
const normalizedPath = filePath.replace(/\\/g, '/');
if (normalizedPath === 'custom' || normalizedPath.startsWith('custom/')) {
basePath = await custom.getPath();
filePath =
normalizedPath === 'custom' ? '' : normalizedPath.substring(normalizedPath.indexOf('/') + 1);
}
return await fs.resolve(basePath, path);
const resolvedPath = await fs.resolve(basePath, filePath);
return resolvedPath;
};

export function initRpc(iframe: HTMLIFrameElement, project: Project, cbs: Partial<Callbacks> = {}) {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/paths.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const SCENES_DIRECTORY = 'Scenes';
export const SETTINGS_DIRECTORY = 'Settings';
export const CUSTOM_ASSETS_DIRECTORY = 'Custom';
export const CUSTOM_ASSETS_DIRECTORY = 'Custom Items';

0 comments on commit 75274a0

Please sign in to comment.