mirror of
https://github.com/atom/atom.git
synced 2026-02-15 00:55:14 -05: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:
52
spec/atom-portable-spec.coffee
Normal file
52
spec/atom-portable-spec.coffee
Normal file
@@ -0,0 +1,52 @@
|
||||
path = require "path"
|
||||
fs = require 'fs-plus'
|
||||
temp = require "temp"
|
||||
rimraf = require "rimraf"
|
||||
AtomPortable = require "../src/browser/atom-portable"
|
||||
|
||||
fdescribe "Portable Mode", ->
|
||||
describe "Windows", ->
|
||||
platform = "win32"
|
||||
|
||||
describe "with ATOM_HOME environment variable", ->
|
||||
environmentAtomHome = "C:\\some\\path"
|
||||
it "returns false", ->
|
||||
expect(AtomPortable.isPortableInstall(platform, environmentAtomHome)).toBe false
|
||||
|
||||
describe "without ATOM_HOME environment variable", ->
|
||||
environmentAtomHome = undefined
|
||||
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)
|
||||
|
||||
describe "with .atom directory sibling to exec", ->
|
||||
beforeEach ->
|
||||
fs.mkdirSync(portableAtomHomePath) if not fs.existsSync(portableAtomHomePath)
|
||||
it "returns true", ->
|
||||
expect(AtomPortable.isPortableInstall(platform, environmentAtomHome)).toBe true
|
||||
|
||||
describe "without .atom directory sibling to exec", ->
|
||||
beforeEach ->
|
||||
rimraf.sync(portableAtomHomePath) if fs.existsSync(portableAtomHomePath)
|
||||
it "returns false", ->
|
||||
expect(AtomPortable.isPortableInstall(platform, environmentAtomHome)).toBe false
|
||||
|
||||
describe "Mac", ->
|
||||
platform = "darwin"
|
||||
it "returns false", ->
|
||||
expect(AtomPortable.isPortableInstall(platform, platform)).toBe false
|
||||
|
||||
describe "Linux", ->
|
||||
platform = "linux"
|
||||
it "returns false", ->
|
||||
expect(AtomPortable.isPortableInstall(platform, platform)).toBe false
|
||||
Reference in New Issue
Block a user