This repository was archived by the owner on Jun 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 1+ fs = require ' fs'
12path = require ' path'
23
34normalizePath = (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
1620getRootDirectoryStatus = (repo ) ->
1721 promise = Promise .resolve ()
You can’t perform that action at this time.
0 commit comments