Make project.resolve work on Windows

This commit is contained in:
Kevin Sawicki
2013-10-28 15:21:08 -07:00
parent 002fc570e7
commit d6159a38d4
2 changed files with 14 additions and 7 deletions

View File

@@ -38,6 +38,18 @@ fsExtensions =
catch e
relativePath
# Public: Is the given path absolute?
#
# * pathToCheck:
# The relative or absolute path to check.
#
# Returns true if the path is absolute, false otherwise.
isAbsolute: (pathToCheck='') ->
if process.platform is 'win32'
pathToResolve[1] is ':' # C:\ style
else
pathToResolve[0] is '/' # /usr style
# Public: Returns true if a file or folder at the specified path exists.
exists: (pathToCheck) ->
# TODO: rename to existsSync
@@ -290,12 +302,7 @@ fsExtensions =
pathToResolve = args.pop()
loadPaths = args
if process.platform is 'win32'
isAbsolute = pathToResolve[1] is ':' # C:\ style
else
isAbsolute = pathToResolve[0] is '/' # /usr style
if isAbsolute
if @isAbsolute(pathToResolve)
if extensions and resolvedPath = @resolveExtension(pathToResolve, extensions)
return resolvedPath
else

View File

@@ -157,7 +157,7 @@ class Project
if uri?.match(/[A-Za-z0-9+-.]+:\/\//) # leave path alone if it has a scheme
uri
else
uri = path.join(@getPath(), uri) unless uri[0] == '/'
uri = path.join(@getPath(), uri) unless fsUtils.isAbsolute(uri)
fsUtils.absolute uri
# Public: Make the given path relative to the project directory.