From 77741b6f3f7d6df600758f1904903321666908e6 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 5 Feb 2015 12:18:51 -0800 Subject: [PATCH] Set ATOM_HOME as early as possible in render process Moves it from window-bootstrap.coffee to index.js so it runs before the coffee cache is registered. Refs #5412 --- src/window-bootstrap.coffee | 11 ----------- static/index.js | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/window-bootstrap.coffee b/src/window-bootstrap.coffee index 60a9a14d5..886ba26dc 100644 --- a/src/window-bootstrap.coffee +++ b/src/window-bootstrap.coffee @@ -1,14 +1,3 @@ -# Ensure ATOM_HOME is always set before anything else is required -unless process.env.ATOM_HOME - if process.platform is 'win32' - home = process.env.USERPROFILE - else - home = process.env.HOME - atomHome = path.join(home, '.atom') - try - atomHome = require('fs').realpathSync(atomHome) - process.env.ATOM_HOME = atomHome - # Like sands through the hourglass, so are the days of our lives. require './window' diff --git a/static/index.js b/static/index.js index 12b149699..e5f84f794 100644 --- a/static/index.js +++ b/static/index.js @@ -13,6 +13,23 @@ window.onload = function() { var fs = require('fs'); var path = require('path'); + // Ensure ATOM_HOME is always set before anything else is required + if (!process.env.ATOM_HOME) { + var home; + if (process.platform === 'win32') { + home = process.env.USERPROFILE; + } else { + home = process.env.HOME; + } + var atomHome = path.join(home, '.atom'); + try { + atomHome = fs.realpathSync(atomHome); + } catch (error) { + // Ignore since the path might just not exist yet. + } + process.env.ATOM_HOME = atomHome; + } + // Skip "?loadSettings=". var rawLoadSettings = decodeURIComponent(location.search.substr(14)); var loadSettings;