Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comments and list #2

Closed
jszabo98 opened this issue Jun 27, 2020 · 9 comments
Closed

comments and list #2

jszabo98 opened this issue Jun 27, 2020 · 9 comments
Assignees
Labels
bug Something isn't working pending feedback

Comments

@jszabo98
Copy link

jszabo98 commented Jun 27, 2020

I don't necessarily put a space after // for comments in my settings.json file. convertfrom-json is more forgiving in powershell 7 than powershell 5 for this. But I've added spaces to work with this module.

This is more on me, but I had copied the defaults.json to settings.json, and it doesn't have a 'list' property, so get-wtcurrent wasn't finding the current profile. I've started over with the settings.json that comes with it.

Btw I like having the settings folder for easy cd:

$WTSettingsFolder = split-path $WTSettingsPath

@jdhitsolutions
Copy link
Owner

jdhitsolutions commented Jun 27, 2020

comments are not standard in json so they are a bit picky to parse which is why I added the space. You've noticed the difference as well between Windows PowerShell and PowerShell 7. I might revisit this to see if there is a better way.

@jdhitsolutions
Copy link
Owner

I'm working on a fix to better handle the settings file. You'll see it in v1.6.0

@jdhitsolutions jdhitsolutions added the bug Something isn't working label Jul 8, 2020
@jdhitsolutions jdhitsolutions self-assigned this Jul 8, 2020
@jdhitsolutions
Copy link
Owner

v1.6.0 has been released to the PowerShell Gallery which should address these issues.

@jdavidboyd
Copy link

Huh, I just updated to v1.6.0, and Powershell 7.0.2 still works as before, but now in Powershell 5 I get:

ConvertFrom-Json : Invalid JSON primitive: .
At C:\Users\dboyd\Documents\WindowsPowerShell\Modules\WTToolBox\1.6.0\functions\private.ps1:43 char:118

  • ... -notmatch $pattern -OR $_ -match "ms-appx:/{3}"}) | ConvertFrom-Json
  •                                                      ~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [ConvertFrom-Json], ArgumentException
    • FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand

I don't see anywhere in my settings.json file where I have '//' without a space afterwards, unless it is in some of the URLs for icons....

@jdhitsolutions
Copy link
Owner

JSON in Windows PowerShell is wacky. Can you post your settings file so I can test with it?

@jdavidboyd
Copy link

Here's my settings.json file.

settings.dboyd.zip

@jdhitsolutions
Copy link
Owner

The json cmdlet in Windows PowerShell is very picky. There's nothing "wrong" with your settings file. The same command works just fine in PS 7.

@jdhitsolutions
Copy link
Owner

This will work in Windows PowerShell:

 get-content .\settings.json | where {$_ -notmatch "//"} | convertfrom-json

@jdavidboyd
Copy link

That didn't quite seem to do it, but when I changed the existing line to be this

$obj = (Get-Content -path $Global:WTSettingsPath).where({$_ -notmatch "^[\t ]*//"}) | ConvertFrom-Json

it all seems to work ok.

Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending feedback
Projects
None yet
Development

No branches or pull requests

3 participants