Skip to content

Change path trim based on running platform.#293

Open
Jtho28 wants to merge 2 commits into
microsoft:masterfrom
Jtho28:master
Open

Change path trim based on running platform.#293
Jtho28 wants to merge 2 commits into
microsoft:masterfrom
Jtho28:master

Conversation

@Jtho28

@Jtho28 Jtho28 commented Sep 6, 2024

Copy link
Copy Markdown

This small change allows pbip publishing to function on unix systems and windows alike without editing the source every time.

@Jtho28

Jtho28 commented Sep 6, 2024

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree [company="Kiewit Corporation"]
@microsoft-github-policy-service agree
@microsoft-github-policy-service agree company="Microsoft"

@Jtho28

Jtho28 commented Sep 6, 2024

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Kiewit Corporation"

@RuiRomano

RuiRomano commented Sep 9, 2024

Copy link
Copy Markdown
Collaborator

@Jtho28 looks like 'uname' is not a standard powershell core commandlet.

I'm thinking on doing something like:

$partPath = $filePath.Replace($itemPathAbs, "")

if ($IsWindows) {
$partPath = $partPath.TrimStart("")
}
else {
$partPath = $partPath.TrimStart("/")
}

$partPath = $partPath.Replace("", "/")

Can you please test the above code if it works for your scenario?

@Jtho28

Jtho28 commented Sep 10, 2024

Copy link
Copy Markdown
Author

@RuiRomano

Yeah this does seem like a more robust solution, I will try it out and test it.

@bibinbastian

Copy link
Copy Markdown

Hi team, any update on this bug?

@Jtho28

Jtho28 commented Sep 16, 2024

Copy link
Copy Markdown
Author

Hi team, any update on this bug?

Not yet, I've haven't looked at it for awhile. I'm going to test out the proposed solution today on Windows and Unix-like systems.

@Jtho28

Jtho28 commented Sep 17, 2024

Copy link
Copy Markdown
Author

So I have a tested solution working on Linux, MacOS, and Windows. It's as simple as this, I did get the $IsWindows from @RuiRomano

if ($IsWindows) {
    $partPath = $filePath.Replace($itemPathAbs, "").TrimStart("\").Replace("\", "/")
}
else {
    $partPath = $filePath.Replace($itemPathAbs, "").TrimStart("/")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants