Giter Club home page Giter Club logo

formatpowershellcode's Introduction

Hi there ๐Ÿ‘‹

formatpowershellcode's People

Contributors

zloeber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

formatpowershellcode's Issues

Format-ScriptExpandParameterBlocks deletes comments

Hi Zachary Loeber,
nice formatting script for Powershell. I just found a bug I guess. It would be great if you can fix that as comments shouldn't be deleted. I just provide you here with a simple example:

Get-Content test.ps1 -raw | Format-ScriptExpandParameterBlocks | clip

test.ps1 consists of:
Param
(
# Information type of log entry
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0,
ParameterSetName = 'Info')]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[Alias("information")]
[System.String]$Info)

After formatting:
param (
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0,
ParameterSetName = 'Info')]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[Alias("information")]
[System.String]$Info
)

The comment is deleted. Can you please fix that?

Thanks
Viki

Infinite new lines

Heya, I've written a script that looks at a directory and runs the formatter every second on all .ps1 files.

When it came to this code,

Write-Host($subs | Format-Table -Property @{name="Option";expression={$global:indexSub;$global:indexSub+=1}}, SubscriptionId, SubscriptionName | Out-String)

The formatter adds a newline to the front of Out-String, eventually it becomes:

Write-Host($subs |
    Format-Table -Property @{name="Option";expression={$global:indexSub;$global:indexSub+=1}}, SubscriptionId, SubscriptionName |



    Out-String)

And that blank space increases ad infinitum.

Format-ScriptFormatCodeIndentation doesn't work after building

Format-ScriptFormatCodeIndentation stops working after release building. It's related to the following code:

$AST = [System.Management.Automation.Language.Parser]::ParseInput($ScriptText, [ref]$Tokens, [ref]$ParseError) 

It will be change after build process is run:

$AST = [System.Management.Automation.Language.Parser]::ParseInput($ScriptText, [System.Management.Automation.PSReference]$Tokens, [System.Management.Automation.PSReference]$ParseError)

It seems types are expanded incorrectly because $Tokens variable will always be empty. If I change it back to [ref] everything works again.

Example 1

I'm hoping that in the real world, your output is better than in the readme ๐Ÿ˜‰

But in the readme you lost the newlines, and you have one line that's 2 lines long.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.