summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorP. F. Chimento <philip.chimento@gmail.com>2014-04-07 14:45:41 -0700
committerP. F. Chimento <philip.chimento@gmail.com>2014-04-07 14:45:41 -0700
commit0a8b3f954122e422bcd609598dbf8d3bb741b541 (patch)
treedc2943eccb3484d200d4e0931a3744386aef2c72
parent4120612ce88aa09de995e3acb584ddbf59a7ae7e (diff)
parent69865546166527075c1daab32737e3288e403bff (diff)
Merge pull request #886 from endlessm/sdk/885
Handled relative symlinks properly in getCurrentFileDir [endlessm/eos-sdk#885]
-rw-r--r--overrides/Endless.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/overrides/Endless.js b/overrides/Endless.js
index 60a42e7..02eed50 100644
--- a/overrides/Endless.js
+++ b/overrides/Endless.js
@@ -10,12 +10,15 @@ function getCurrentFileDir() {
let caller = e.stack.split('\n')[1];
let pathAndLine = caller.split('@')[1];
let path = pathAndLine.split(':')[0];
- while (GLib.file_test(path, GLib.FileTest.IS_SYMLINK)) {
- path = GLib.file_read_link(path);
+ let file = Gio.File.new_for_path(path);
+ while (GLib.file_test(file.get_path(), GLib.FileTest.IS_SYMLINK)) {
+ let link_path = GLib.file_read_link(file.get_path());
+ // link_path may be relative, we need to resolve it from current dir
+ file = file.get_parent().resolve_relative_path(link_path);
}
// Get full path from GIO
- return Gio.File.new_for_path(path).get_parent().get_path();
+ return file.get_parent().get_path();
}
imports.searchPath.unshift(getCurrentFileDir());