mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Implement Portable Mode
According to these specifications: Portable mode only applies to Windows (for now) Portable mode only applies if ATOM_HOME is not set If there is a .atom directory as sibling to directory with running process use that as ATOM_HOME
This commit is contained in:
15
src/browser/atom-portable.coffee
Normal file
15
src/browser/atom-portable.coffee
Normal file
@@ -0,0 +1,15 @@
|
||||
fs = require 'fs-plus'
|
||||
path = require 'path'
|
||||
|
||||
module.exports =
|
||||
class AtomPortable
|
||||
@portableAtomHomePath: ->
|
||||
execDirectoryPath = path.dirname(process.execPath)
|
||||
return path.join(execDirectoryPath, "../.atom")
|
||||
@isPortableInstall: (platform, environmentAtomHome) ->
|
||||
return false unless platform is 'win32'
|
||||
return false if environmentAtomHome
|
||||
|
||||
# currently checking only that the directory exists, probably want to do
|
||||
# some integrity checks on contents and make sure it's writable in future
|
||||
return fs.existsSync(@portableAtomHomePath())
|
||||
@@ -57,23 +57,13 @@ handleStartupEventWithSquirrel = ->
|
||||
setupCrashReporter = ->
|
||||
crashReporter.start(productName: 'Atom', companyName: 'GitHub')
|
||||
|
||||
isPortableInstall = (args) ->
|
||||
return false unless process.platform is 'win32'
|
||||
return false unless (process and process.type)
|
||||
return false if args.devMode or args.testMode
|
||||
|
||||
ourPath = process.execPath.toLowerCase()
|
||||
return (ourPath.indexOf(process.env.LOCALAPPDATA.toLowerCase()) is 0)
|
||||
|
||||
setupAtomHome = (args) ->
|
||||
return if process.env.ATOM_HOME
|
||||
|
||||
atomHome = path.join(app.getHomeDir(), '.atom')
|
||||
try
|
||||
atomHome = fs.realpathSync(atomHome)
|
||||
fs.statSync(atomHome)
|
||||
catch
|
||||
atomHome = path.join(path.dirname(process.execPath), '.atom') if isPortableInstall(args)
|
||||
AtomPortable = require './atom-portable'
|
||||
atomHome = AtomPortable.portableAtomHomePath() if AtomPortable.isPortableInstall process.platform, process.env.ATOM_HOME
|
||||
atomHome = fs.realpathSync(atomHome)
|
||||
fs.statSync(atomHome)
|
||||
|
||||
process.env.ATOM_HOME = atomHome
|
||||
|
||||
|
||||
Reference in New Issue
Block a user