Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Rig getAtomDirectory to understand Win32 Portable Mode #421

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/apm.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,25 @@ module.exports =
getHomeDirectory: ->
if process.platform is 'win32' then process.env.USERPROFILE else process.env.HOME

isPortableInstall: ->
return false unless process.platform is 'win32'

return false unless (process and process.type)

ourPath = process.execPath.toLowerCase()
return (ourPath.indexOf(process.env.LOCALAPPDATA.toLowerCase()) is 0)

getAtomDirectory: ->
process.env.ATOM_HOME ? path.join(@getHomeDirectory(), '.atom')
ret = process.env.ATOM_HOME ? path.join(@getHomeDirectory(), '.atom')

# Does the non-Portable settings folder exist? Exit
return ret if fs.statSyncNoException(ret)

# Are we installed in a portable way?
return ret unless @isPortableInstall()

# Portable Mode!
return path.join(path.dirname(process.execPath), '.atom')

getCacheDirectory: ->
path.join(@getAtomDirectory(), '.apm')
Expand Down