mirror of
https://github.com/atom/atom.git
synced 2026-02-18 18:34:21 -05:00
Enable Portable Mode
This PR sets the default ATOM_HOME to be relative to atom.exe, if the following cases are true: 1. We're not in DevMode 1. We're on Windows 1. The EXE path is not in the normal installed location This allows users to take the entire Atom folder and use it as a "Portable" application (i.e. portableapps.com)
This commit is contained in:
@@ -40,6 +40,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
function isPortableMode() {
|
||||
// No portable mode on non-Windows
|
||||
if (process.platform !== 'win32') return false
|
||||
|
||||
// DevMode? Nope
|
||||
var devMode = loadSettings &&
|
||||
(loadSettings.devMode || !loadSettings.resourcePath.startsWith(process.resourcesPath + path.sep))
|
||||
|
||||
if (devMode) return false
|
||||
|
||||
// Compare our EXE's path to where it would normally be in an installed app
|
||||
var ourPath = process.execPath.toLowerCase()
|
||||
return (ourPath.indexOf(process.env.LOCALAPPDATA.toLowerCase()) === 0)
|
||||
}
|
||||
|
||||
function setLoadTime (loadTime) {
|
||||
if (global.atom) {
|
||||
global.atom.loadTime = loadTime
|
||||
@@ -95,7 +110,11 @@
|
||||
try {
|
||||
atomHome = fs.realpathSync(atomHome)
|
||||
} catch (error) {
|
||||
// Ignore since the path might just not exist yet.
|
||||
// If we're in portable mode *and* the user doesn't already have a .atom
|
||||
// folder in the normal place, we'll use the portable folder instead
|
||||
if (isPortableMode()) {
|
||||
atomHome = path.join(path.dirname(process.execPath), '.atom')
|
||||
}
|
||||
}
|
||||
process.env.ATOM_HOME = atomHome
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user