在 Gedit 中缩小 JavaScript 时命令行 JavaScript 输入参数问题
我想立即在 Gedit 中缩小我的 JavaScript 文件。我尝试使用 jsmin.js 脚本通过外部工具选项来完成此操作。我安装了 SpiderMonkey 引擎。我将 jsmin.js 文件存储在 /home/mushex/use/js/jsmin.js 并创建了一个名为 jsmin-low.js 的新 js 文件em> 与 content 在同一目录中
#!/usr/bin/js
load('/home/mushex/use/js/jsmin.js');
var body = arguments[0],
result = jsmin('', body, 1);
if (result) {
print(result);
} else {
print(body);
}
打印出 undefined。为了调试,我已将脚本更改为仅在参数打印操作中执行,并看到输入为空(未定义)。用于调试的文件源是
#!/usr/bin/js
print(arguments[0]);
但是当我在命令行中运行它时,它的输出是正确的。并且通过gedit其他js命令行工具工作正常。徘徊为什么我的输入参数没有通过。
以下是我在 gedit 中为此工具设置的设置。
设置 http://imagebin.org/index.php?mode=image&id =63960
任何帮助将不胜感激 谢谢。
I want to minify my JavaScript files immediately in Gedit. I tried do it via external tools option with jsmin.js script. I have SpiderMonkey engine installed. I stored jsmin.js file at /home/mushex/use/js/jsmin.js and created a new js file named jsmin-low.js in the same directory with content
#!/usr/bin/js
load('/home/mushex/use/js/jsmin.js');
var body = arguments[0],
result = jsmin('', body, 1);
if (result) {
print(result);
} else {
print(body);
}
It prints out undefined. For debugging I've changed script to perform only in argument printing action , and saw that input is null (undefined). Source of file for debugging was
#!/usr/bin/js
print(arguments[0]);
But when I'm running it in command line it's output is correct. And via gedit other js command line tools are working normal. Wandering why my input arguments don't passing.
Here are settings I set for this tool in gedit.
Settings http://imagebin.org/index.php?mode=image&id=63960
Any help will be greatly appreciated
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是 gedit 正在将文档发送到程序的标准输入中,而不是作为命令行参数。 SpiderMonkey shell 有一个 readline() 函数,可以从 stdin 读取一行,但它无法知道何时到达 EOF。
如果您编译带有
File
支持的 SpiderMonkey,您可能可以做到,但我从未尝试过。如果您使用 Rhino shell,您可以直接使用 Java 类,如下所示:
The problem is that gedit is sending the document into your program's standard input, not as a command-line argument. The SpiderMonkey shell has a
readline()
function that reads a line from stdin, but it doesn't have a way of knowing when you reach EOF.If you compile SpiderMonkey with
File
support, you could probably do it, but I've never tried that.If you use the Rhino shell, you can use Java classes directly like this: