PoshCode / Configuration

A module to help other modules have settings
MIT License
176 stars 27 forks source link

Cross-platform support? #13

Closed devblackops closed 6 years ago

devblackops commented 6 years ago

@Jaykul Any there any plans/desire to add cross-platform support to this module?

Skimming through the source, I don't see anything that would prevent this module from working on Linux/MacOS (other than the use of Windows-specific environment variables for where to store the configuration(s).

Jaykul commented 6 years ago

You should be able use it by specifying the storage paths on import (as we do in testing), or just setting the environment variables for AppData, LocalAppData, and ProgramData (that is, machine AppData). It's all on lines 4-7

But I'm not sure what paths to use on linux, or how to determine across all the supported distros, so I haven't fixed it yet. Any thoughts?

I'd be willing to loose the separation of "user" vs "user roaming" to support the lowest common denominator if need be, but what paths would need to be used for User-specific vs Machine-wide settings?

scrthq commented 6 years ago

for the user profile, you could abstract the environment variable aspect and use $UserData = (Join-Path "~" "\AppData\Local"), then create the folder structure if not there (this is what the AWS .NET SDK does for the SDKCredentialStore, albeit clunky and not very OS agnostic feeling)

devblackops commented 6 years ago

I don't know if there is really an equivalent for $env:AppData in *nix.

I think the logical mapping of $env:ProgramData and $env:LocalAppData would be:

Anyone with more *nix experience feel free to correct me.

RamblingCookieMonster commented 6 years ago

Ran into some of this toying with psneo4j xplat. Another thing to change is the mkdir call. IIRC that, along with the overridden paths, got things up and running.

Cheers!

Jaykul commented 6 years ago

@RamblingCookieMonster did they remove that function on Linux, or am I missing something?

RamblingCookieMonster commented 6 years ago

They do! just... not with -Force - changed it to New-Item -ItemType Directory

Jaykul commented 6 years ago

That's ok, I just recently became aware that -Force is flawed (if there's file and you're trying to make a folder, it silently does ... nothing). We should make that ... safer.

Jaykul commented 6 years ago

Any of you willing to pull my /dev branch, run build, and try it on OS X or Linux? ;)

Jaykul commented 6 years ago

OK. Fine. I've got the tests working on Linux and it's ... working. Shipped 1.2.0 Open new issues if there any problems 😁