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

Commit

Permalink
Merge pull request #58 from tlex:add_support_symlink_project_folders
Browse files Browse the repository at this point in the history
  • Loading branch information
subesokun committed Apr 8, 2018
2 parents f0d7969 + 35f25c9 commit f054387
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/utils.coffee
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
fs = require 'fs'
path = require 'path'

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

getRootDirectoryStatus = (repo) ->
promise = Promise.resolve()
Expand Down

0 comments on commit f054387

Please sign in to comment.