-
Notifications
You must be signed in to change notification settings - Fork 98
Script file info cmdlets #602
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
Conversation
… Hashtable[] RequiredModules
…ut variable for udpated one
…ves in AfterAll block
src/code/PSScriptFileInfo.cs
Outdated
@@ -386,18 +386,48 @@ .VERSION 1.0 | |||
return false; | |||
} | |||
|
|||
keyName = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like both keyName
and value
are only used within the for loop below. So they can be defined there (in that scope) instead of here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, in the latest commit this is in a helper method GetMetadataFromCommentLines().
We need the keyName
and value
variables defined outside the for loop, as we're iterating through lines of the metadata string. When grabbing the key name and value, the value can continue onto the next line. So for certain metadata properties we may not get all the value on that line/within the current iteration of the for loop.
|
||
// get end of file contents | ||
string[] totalFileContents = File.ReadAllLines(scriptFileInfoPath); | ||
var contentAfterAndIncludingDescription = totalFileContents.SkipWhile(x => !x.Contains(".DESCRIPTION")).ToList(); | ||
var contentAfterDescription = contentAfterAndIncludingDescription.SkipWhile(x => !x.Contains("#>")).Skip(1).ToList(); | ||
endOfFileContents = String.Join("\n", contentAfterDescription.ToArray()); | ||
endOfFileContents = String.Join("\n", contentAfterAndIncludingDescription.SkipWhile(x => !x.Contains("#>")).Skip(1).ToArray()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about this. It is not clear what this is doing and whether script content, that can also include comments, is always included in endOfFileContents. Instead of using LINQ I would prefer to see a utility method that is a bit more explicit about what it is doing.
this PR willl be closed in favor of #708 |
PR Summary
PR Context
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.