This repository was archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17.3k
Enable Portable Mode #8442
Merged
Merged
Enable Portable Mode #8442
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
d620da3
Enable Portable Mode
anaisbetts 4a53619
Patch the browser process too
anaisbetts 4775595
Correctly handle devMode
anaisbetts 2f6b678
Merge remote-tracking branch 'atom/master'
raelyard f067fdb
Merge branch 'master' into portable-mode
raelyard b8a1537
Implement Portable Mode
raelyard db57479
Remove superfluous check on ATOM_HOME
raelyard 28c322a
Fix broken focused suite in spec
raelyard 4312f76
Added command line parameter to set portable
raelyard 16c2391
Add notification if Portable Home not writable
raelyard 265ee01
Clean convention inconsistencies for portable mode
raelyard 28a1bbf
Fix function names - consistent with convention
raelyard ef71211
Always include portable home path in warning
raelyard bcfb6ab
Remove explicit returns
raelyard 82f5e81
Restore check on ATOM_HOME
raelyard 03faddd
Undo add command line parameter to set portable
raelyard 6d4105a
Escape characters is portable path not writable
raelyard 8652890
Simplify markdown escaping for warning
raelyard e0697ec
Merge branch 'master' into portable-mode
raelyard e93b013
Remove unused function parameter
raelyard 810f0e4
Fix merge problem and missing function call
raelyard 3534589
Fix function name to be consistent with convention
raelyard 8acb2af
Remove unused parameter
raelyard b1d10ef
Revert moving parse of command line
raelyard 02fe2cf
:art:
kevinsawicki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
path = require "path" | ||
fs = require 'fs-plus' | ||
temp = require "temp" | ||
rimraf = require "rimraf" | ||
AtomPortable = require "../src/browser/atom-portable" | ||
|
||
describe "Check for Portable Mode", -> | ||
describe "Windows", -> | ||
describe "with ATOM_HOME environment variable", -> | ||
it "returns false", -> | ||
expect(AtomPortable.isPortableInstall("win32", "C:\\some\\path")).toBe false | ||
|
||
describe "without ATOM_HOME environment variable", -> | ||
environmentAtomHome = undefined | ||
portableAtomHomePath = path.join(path.dirname(process.execPath), "..", ".atom") | ||
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("win32", environmentAtomHome)).toBe true | ||
|
||
describe "without .atom directory sibling to exec", -> | ||
beforeEach -> | ||
rimraf.sync(portableAtomHomePath) if fs.existsSync(portableAtomHomePath) | ||
|
||
it "returns false", -> | ||
expect(AtomPortable.isPortableInstall("win32", environmentAtomHome)).toBe false | ||
|
||
describe "Mac", -> | ||
it "returns false", -> | ||
expect(AtomPortable.isPortableInstall("darwin", "darwin")).toBe false | ||
|
||
describe "Linux", -> | ||
it "returns false", -> | ||
expect(AtomPortable.isPortableInstall("linux", "linux")).toBe false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
fs = require 'fs-plus' | ||
path = require 'path' | ||
ipc = require 'ipc' | ||
|
||
module.exports = | ||
class AtomPortable | ||
@getPortableAtomHomePath: -> | ||
execDirectoryPath = path.dirname(process.execPath) | ||
path.join(execDirectoryPath, '..', '.atom') | ||
|
||
@isPortableInstall: (platform, environmentAtomHome, defaultHome) -> | ||
return false unless platform is 'win32' | ||
return false if environmentAtomHome | ||
return false if not fs.existsSync(@getPortableAtomHomePath()) | ||
# currently checking only that the directory exists and is writable, | ||
# probably want to do some integrity checks on contents in future | ||
@isPortableAtomHomePathWritable(defaultHome) | ||
|
||
@isPortableAtomHomePathWritable: (defaultHome) -> | ||
writable = false | ||
message = "" | ||
try | ||
writePermissionTestFile = path.join(@getPortableAtomHomePath(), "write.test") | ||
fs.writeFileSync(writePermissionTestFile, "test") if not fs.existsSync(writePermissionTestFile) | ||
fs.removeSync(writePermissionTestFile) | ||
writable = true | ||
catch error | ||
message = "Failed to use portable Atom home directory (#{@getPortableAtomHomePath()}). Using the default instead (#{defaultHome}). #{error.message}" | ||
|
||
ipc.on 'check-portable-home-writable', (event) -> | ||
event.sender.send 'check-portable-home-writable-response', {writable, message} | ||
writable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️