mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Added command line parameter to set portable
If parameter included, home directory will be copied to the portable location to make this a portable install
This commit is contained in:
@@ -4,7 +4,26 @@ temp = require "temp"
|
||||
rimraf = require "rimraf"
|
||||
AtomPortable = require "../src/browser/atom-portable"
|
||||
|
||||
describe "Portable Mode", ->
|
||||
describe "Set Portable Mode", ->
|
||||
portableAtomHomePath = path.join(path.dirname(process.execPath), "../.atom").toString()
|
||||
portableAtomHomeNaturallyExists = fs.existsSync(portableAtomHomePath)
|
||||
portableAtomHomeBackupPath = portableAtomHomePath + ".temp"
|
||||
|
||||
beforeEach ->
|
||||
fs.renameSync(portableAtomHomePath, portableAtomHomeBackupPath) if fs.existsSync(portableAtomHomePath)
|
||||
|
||||
afterEach ->
|
||||
if portableAtomHomeNaturallyExists
|
||||
fs.renameSync(portableAtomHomeBackupPath, portableAtomHomePath) if not fs.existsSync(portableAtomHomePath)
|
||||
else
|
||||
rimraf.sync(portableAtomHomePath) if fs.existsSync(portableAtomHomePath)
|
||||
rimraf.sync(portableAtomHomeBackupPath) if fs.existsSync(portableAtomHomeBackupPath)
|
||||
|
||||
it "creates portable home directory", ->
|
||||
AtomPortable.setPortable(process.env.ATOM_HOME)
|
||||
expect(fs.existsSync(portableAtomHomePath)).toBe true
|
||||
|
||||
describe "Check for Portable Mode", ->
|
||||
describe "Windows", ->
|
||||
platform = "win32"
|
||||
|
||||
|
||||
@@ -5,7 +5,11 @@ module.exports =
|
||||
class AtomPortable
|
||||
@portableAtomHomePath: ->
|
||||
execDirectoryPath = path.dirname(process.execPath)
|
||||
return path.join(execDirectoryPath, "../.atom")
|
||||
return path.join(execDirectoryPath, "../.atom/")
|
||||
|
||||
@setPortable: (existingAtomHome) ->
|
||||
fs.copySync(existingAtomHome, @portableAtomHomePath())
|
||||
|
||||
@isPortableInstall: (platform, environmentAtomHome) ->
|
||||
return false unless platform is 'win32'
|
||||
return false if environmentAtomHome
|
||||
|
||||
@@ -61,6 +61,7 @@ setupAtomHome = (args) ->
|
||||
return if process.env.ATOM_HOME
|
||||
atomHome = path.join(app.getHomeDir(), '.atom')
|
||||
AtomPortable = require './atom-portable'
|
||||
AtomPortable.setPortable(atomHome) if not AtomPortable.isPortableInstall(process.platform, process.env.ATOM_HOME) and args.setPortable
|
||||
atomHome = AtomPortable.portableAtomHomePath() if AtomPortable.isPortableInstall process.platform, process.env.ATOM_HOME
|
||||
atomHome = fs.realpathSync(atomHome)
|
||||
fs.statSync(atomHome)
|
||||
@@ -107,6 +108,7 @@ parseCommandLine = ->
|
||||
options.alias('t', 'test').boolean('t').describe('t', 'Run the specified specs and exit with error code on failures.')
|
||||
options.alias('v', 'version').boolean('v').describe('v', 'Print the version.')
|
||||
options.alias('w', 'wait').boolean('w').describe('w', 'Wait for window to be closed before returning.')
|
||||
options.alias('p', 'set-portable').boolean('p').describe('p', 'Set portable mode.')
|
||||
options.string('socket-path')
|
||||
|
||||
args = options.argv
|
||||
@@ -132,6 +134,7 @@ parseCommandLine = ->
|
||||
profileStartup = args['profile-startup']
|
||||
urlsToOpen = []
|
||||
devResourcePath = process.env.ATOM_DEV_RESOURCE_PATH ? path.join(app.getHomeDir(), 'github', 'atom')
|
||||
setPortable = args['set-portable']
|
||||
|
||||
if args['resource-path']
|
||||
devMode = true
|
||||
@@ -161,6 +164,6 @@ parseCommandLine = ->
|
||||
|
||||
{resourcePath, devResourcePath, pathsToOpen, urlsToOpen, executedFrom, test,
|
||||
version, pidToKillWhenClosed, devMode, safeMode, newWindow, specDirectory,
|
||||
logFile, socketPath, profileStartup}
|
||||
logFile, socketPath, profileStartup, setPortable}
|
||||
|
||||
start()
|
||||
|
||||
Reference in New Issue
Block a user