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

Commit f054387

Browse files
committed
Merge pull request #58 from tlex:add_support_symlink_project_folders
2 parents f0d7969 + 35f25c9 commit f054387

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/utils.coffee

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
fs = require 'fs'
12
path = require 'path'
23

34
normalizePath = (repoPath) ->
4-
normPath = path.normalize repoPath
5+
normPath = (path.normalize repoPath).replace(/[\\\/]$/, '')
56
if process.platform is 'darwin'
67
# For some reason the paths returned by the tree-view and
78
# git-utils are sometimes "different" on Darwin platforms.
89
# E.g. /private/var/... (real path) !== /var/... (symlink)
910
# For now just strip away the /private part.
10-
# Using the fs.realPath function to avoid this issue isn't such a good
11-
# idea because it tries to access that path and in case it's not
12-
# existing path an error gets thrown + it's slow due to fs access.
1311
normPath = normPath.replace(/^\/private/, '')
14-
return normPath.replace(/[\\\/]$/, '')
12+
try
13+
# Finally try to resolve the real path to avoid issues with symlinks.
14+
return fs.realpathSync(normPath)
15+
catch e
16+
# If the path doesn't exists `realpath` throws an error.
17+
# In that case just return the normalized path.
18+
return normPath
1519

1620
getRootDirectoryStatus = (repo) ->
1721
promise = Promise.resolve()

0 commit comments

Comments
 (0)