[gnome-weather] package: improve detection of source trees



commit bcc108eef06e9c793ae000a924fde4919e397d7c
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Tue May 7 22:37:04 2013 +0200

    package: improve detection of source trees
    
    Recent gjs (>= 1.36) has the API we need to avoid hacks when
    deciding to load local or installed files.

 src/package.js |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/package.js b/src/package.js
index 26f26d1..89685c6 100644
--- a/src/package.js
+++ b/src/package.js
@@ -44,6 +44,19 @@ var localedir;
 let _base;
 let _requires;
 
+function _runningFromSource(name) {
+    if (System.version >= 13600) {
+        let fileName = System.programInvocationName;
+
+        let binary = Gio.File.new_for_path(fileName);
+        let cwd = Gio.File.new_for_path('.');
+        return binary.has_prefix(cwd);
+    } else {
+        return GLib.file_test(name + '.doap',
+                              GLib.FileTest.EXISTS);
+    }
+}
+
 /**
  * init:
  * @params: package parameters
@@ -100,8 +113,7 @@ function init(params) {
     datadir = GLib.build_filenamev([prefix, 'share']);
     let libpath, girpath;
 
-    if (GLib.file_test(name + '.doap',
-                       GLib.FileTest.EXISTS)) {
+    if (_runningFromSource(name)) {
         log('Running from source tree, using local files');
         // Running from source directory
         _base = GLib.get_current_dir();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]