在 OSA 脚本中使用Application.currentApplication()
时,它会在从命令行运行时发出以下警告:
warning: failed to get scripting definition from /usr/bin/osascript; it may not be scriptable.
为什么会发生这种情况以及可以做些什么呢?
例子
应用程序.js:
#!/usr/bin/env osascript -l JavaScript
var app = Application.currentApplication();
app.includeStandardAdditions = true;
console.log('Hello, I’m ' + app.pathTo(this));
外壳输出:
❯❯❯ ./app.js
2015-03-01 12:39:29.611 app.js[65539:6266286] warning: failed to get scripting definition from /usr/bin/osascript; it may not be scriptable.
Hello, I’m /Users/aaron/Desktop/app.js