Merge pull request #13605 from atom/dg-correct-portable-path-windows

Correct the portable path location on Windows
This commit is contained in:
Damien Guard 2017-01-14 09:35:27 -08:00 committed by GitHub
commit 623caaf85d
2 changed files with 3 additions and 4 deletions

View File

@ -8,8 +8,7 @@ import path from 'path'
const temp = require('temp').track()
describe("AtomPaths", () => {
const portableAtomHomePath = path.join(atomPaths.getAppDirectory(), '.atom')
console.log(portableAtomHomePath)
const portableAtomHomePath = path.join(atomPaths.getAppDirectory(), '..', '.atom')
afterEach(() => {
atomPaths.setAtomHome(app.getPath('home'))

View File

@ -17,7 +17,7 @@ const hasWriteAccess = (dir) => {
const getAppDirectory = () => {
switch (process.platform) {
case 'darwin':
return path.join(process.execPath.substring(0, process.execPath.indexOf('.app')), '..')
return process.execPath.substring(0, process.execPath.indexOf('.app') + 4)
case 'linux':
case 'win32':
return path.join(process.execPath, '..')
@ -27,7 +27,7 @@ const getAppDirectory = () => {
module.exports = {
setAtomHome: (homePath) => {
// When a read-writeable .atom folder exists above app use that
const portableHomePath = path.join(getAppDirectory(), '.atom')
const portableHomePath = path.join(getAppDirectory(), '..', '.atom')
if (fs.existsSync(portableHomePath)) {
if (hasWriteAccess(portableHomePath)) {
process.env.ATOM_HOME = portableHomePath