Having trouble passing parameters to a program within powershell
I'm using yuicompressor to minify and obfuscate some javscript files. I'm trying to dynamically build the file path and pass it to the minifier from powershell.
Here's what works:
$results = java -jar c:\yui\yuicompressor-2.4.2.jar c:\MyFile.js -v --charset utf-8
Here's what doesn't开发者_如何学Go work:
$yuiPath = "c:\yui\yuicompressor-2.4.2.jar"
$filePath = "c:\MyFile.js"
$results = java -jar $yuiPath $filePath -v --charset utf-8
It's apparently not liking the $filePath -v --charset utf-8
part because I successfully get the yuicompressor help text when I run it. Any suggestions?
I figured it out. The path to the file "c:\MyFile" didn't actually have the extension so I needed to pass --type js
as an argument
May be you can use Join-Path cmdlet and try it out.
精彩评论