Extendscript获取调用者函数文件路径

时间:2016-06-06 08:21:15

标签: javascript watch extendscript

我正在尝试获取调用函数的文件路径。就像在这个例子中一样:

项目路径:#include './test.jsx'; someFunc();

index.jsx:

function someFunc() {
    return callerFilePath();
}

test.jsx:

$.watch('fileName', function(prop, oldval, newval) {
    doSomething();
});

预期结果(以下之一):

  • C:/project/some-project/index.jsx
  • ./ index.js

我尝试将观察者添加到$ object中,如:

$.evalFile()

但它似乎只适用于我改变的道具,而不是核心。 还尝试了col-xx-n;

提前致谢!

1 个答案:

答案 0 :(得分:0)

此设置应该为您提供函数所在文件的路径。

文件夹结构:

├── index.jsx
└── sub-folder
    └── include.jsx

index.jsx的内容

//@include "sub-folder/include.jsx"
$.writeln(getPath());

include.jsx的内容

function getPath (){
  return $.fileName;
}
相关问题