]> khamidou — GitHub mirrors - electron.git/commitdiff
Implment app.getAppPath API.
authorHaojian Wu <hokein.wu@gmail.com>
Mon, 6 Jul 2015 09:35:35 +0000 (17:35 +0800)
committerHaojian Wu <hokein.wu@gmail.com>
Tue, 7 Jul 2015 09:37:53 +0000 (17:37 +0800)
atom/browser/api/lib/app.coffee
atom/browser/default_app/main.js
atom/browser/lib/init.coffee
docs/api/app.md

index a2ec8bd10c9f2a36bd018a3e0916b3bc76474197..3e05106d1927b8715e0eeaa1dbbabaa33e29e0fb 100644 (file)
@@ -25,6 +25,13 @@ if process.platform is 'darwin'
     show: bindings.dockShow
     setMenu: bindings.dockSetMenu
 
+appPath = null
+app.setAppPath = (path) ->
+  appPath = path
+
+app.getAppPath = ->
+  appPath
+
 # Be compatible with old API.
 app.once 'ready', -> @emit 'finish-launching'
 app.terminate = app.quit
index 567cc118e25b7335ccda38cdeafcc7a5c1a3a1cd..838cb4c2bb2e80405d277a728e36c5b5d0a49fd9 100644 (file)
@@ -291,6 +291,7 @@ if (option.file && !option.webdriver) {
         app.setName(packageJson.name);
       app.setPath('userData', path.join(app.getPath('appData'), app.getName()));
       app.setPath('userCache', path.join(app.getPath('cache'), app.getName()));
+      app.setAppPath(packagePath);
     }
 
     // Run the app.
index cbee1365541686393d53916faf21f9fa42762a79..678d7422b0c6896ad3f2b7fb6aa1a51f35c232b9 100644 (file)
@@ -87,6 +87,7 @@ app.commandLine.appendSwitch 'enable-npapi'
 # Set the user path according to application's name.
 app.setPath 'userData', path.join(app.getPath('appData'), app.getName())
 app.setPath 'userCache', path.join(app.getPath('cache'), app.getName())
+app.setAppPath packagePath
 
 # Load the chrome extension support.
 require './chrome-extension'
index 89df0e7bde999ffeb4e4268b04aded802dff58a5..99576c4e4161b2ab9797c4fdf3d7c15bdae70e59 100644 (file)
@@ -139,6 +139,10 @@ This method guarantees all `beforeunload` and `unload` handlers are correctly
 executed. It is possible that a window cancels the quitting by returning
 `false` in `beforeunload` handler.
 
+## app.getAppPath()
+
+Returns the current application directory.
+
 ## app.getPath(name)
 
 * `name` String