Skip to content

Commit

Permalink
Fix minor windows path issue
Browse files Browse the repository at this point in the history
  • Loading branch information
TheApplePieGod committed Jan 8, 2024
1 parent 81be4e8 commit 3b0014e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions client/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ async fn tauri_api(
Ok(vec!(final_path.to_str().unwrap().to_string()))
},
"path.relative" => {
let final_path = RelativePath::new(&args[0])
.relative(&args[1]);
Ok(vec!(final_path.to_string()))
let path_from = RelativePath::new(&args[0]);
let path_to = RelativePath::new(&args[1]);
let result = path_from.relative(path_to);
Ok(vec!(result.to_string()))
},
"path.dirname" => {
let path = Path::new(&args[0]).parent().unwrap_or(Path::new(""));
Expand Down
9 changes: 7 additions & 2 deletions client/src/components/sidebar/runner/scaffold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,13 @@ async function fetchData(scaffoldPath: string) {
file.endsWith('RobotPlayer.scala')
)
.map(async (file) => {
const relPath = await path.relative(sourcePath, file)
const botName = relPath.split(sep)[0] // Name of folder
// Relative path will contain the folder and filename, so we can split on the separator
// to get the folder name. We must first normalize the path to have forward slashes in the
// case of windows so the relative path function works correctly
const p1 = sourcePath.replace(/\\/g, '/')
const p2 = file.replace(/\\/g, '/')
const relPath = (await path.relative(p1, p2)).replace(/\\/g, '/')
const botName = relPath.split('/')[0]
return botName
})
)
Expand Down

0 comments on commit 3b0014e

Please sign in to comment.