chocolatey / package-validator

Windows service to validate packages conform to package standards
Apache License 2.0
31 stars 29 forks source link

Checking for commands instead of comments #110

Open ferventcoder opened 8 years ago

ferventcoder commented 8 years ago

Some of our validation stuff is a bit primitive in its checks through the powershell scripts. We should instead do this

Collection<PSParseError> errors = null;
var tokens = PSParser.Tokenize(contents, out errors);

var requiredCalls = tokens.Where(p => p.Type != PSTokenType.Comment && 
  (
    p.Content.to_lower().Contains("get-webfile") ||
    p.Content.to_lower().Contains("something")
  )
);

This we can do to avoid flagging on cinst/cup/choco upgrades and when checking for the presence of certain commands in the scripts.