在 powershell 中将参数传递给程序时遇到问题
我正在使用 yuicompressor 来缩小和混淆一些 javscript 文件。我正在尝试动态构建文件路径并将其从 powershell 传递给压缩器。
这是有效的:
$results = java -jar c:\yui\yuicompressor-2.4.2.jar c:\MyFile.js -v --charset utf-8
这是无效的:
$yuiPath = "c:\yui\yuicompressor-2.4.2.jar"
$filePath = "c:\MyFile.js"
$results = java -jar $yuiPath $filePath -v --charset utf-8
它显然不喜欢 $filePath -v --charset utf-8
部分,因为我在运行它时成功获得了 yuicompressor 帮助文本。有什么建议吗?
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 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想通了。文件“c:\MyFile”的路径实际上没有扩展名,因此我需要传递
--type js
作为参数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也许您可以使用 Join-Path cmdlet 并尝试一下。
May be you can use Join-Path cmdlet and try it out.