From e7064bfc9d8e6663be076390ebd9d752e5bc3fb1 Mon Sep 17 00:00:00 2001 From: Mostafa Eweda Date: Tue, 19 May 2015 19:04:54 -0700 Subject: [PATCH] Fix tests + add integration test --- spec/integration/startup-spec.coffee | 10 ++++++++++ src/browser/main.coffee | 9 ++++++--- src/default-directory-provider.coffee | 14 +++++++++----- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/spec/integration/startup-spec.coffee b/spec/integration/startup-spec.coffee index 54817fedc..d2583ed27 100644 --- a/spec/integration/startup-spec.coffee +++ b/spec/integration/startup-spec.coffee @@ -227,3 +227,13 @@ describe "Starting Atom", -> [tempDirPath] [otherTempDirPath] ].sort() + + describe "opening a remote directory", -> + it "opens the parent directory and creates an empty text editor", -> + remoteDirectory = 'remote://server:3437/some/directory/path' + runAtom [remoteDirectory], {ATOM_HOME: atomHome}, (client) -> + client + .waitForWindowCount(1, 1000) + .waitForExist("atom-workspace", 5000) + .treeViewRootDirectories() + .then ({value}) -> expect(value).toEqual([remoteDirectory]) diff --git a/src/browser/main.coffee b/src/browser/main.coffee index 1af0526dd..a15a53f25 100644 --- a/src/browser/main.coffee +++ b/src/browser/main.coffee @@ -5,6 +5,7 @@ app = require 'app' fs = require 'fs-plus' path = require 'path' yargs = require 'yargs' +url = require 'url' nslog = require 'nslog' console.log = nslog @@ -45,9 +46,11 @@ start = -> cwd = args.executedFrom?.toString() or process.cwd() args.pathsToOpen = args.pathsToOpen.map (pathToOpen) -> - pathToOpen = fs.normalize(pathToOpen) - if cwd - path.resolve(cwd, pathToOpen) + normalizedPath = fs.normalize(pathToOpen) + if url.parse(pathToOpen || '').protocol? + pathToOpen + else if cwd + path.resolve(cwd, normalizedPath) else path.resolve(pathToOpen) diff --git a/src/default-directory-provider.coffee b/src/default-directory-provider.coffee index 3257b9ac5..01de244d8 100644 --- a/src/default-directory-provider.coffee +++ b/src/default-directory-provider.coffee @@ -15,14 +15,18 @@ class DefaultDirectoryProvider # * {Directory} if the given URI is compatible with this provider. # * `null` if the given URI is not compatibile with this provider. directoryForURISync: (uri) -> - directoryPath = if not fs.isDirectorySync(uri) and fs.isDirectorySync(path.dirname(uri)) - path.normalize(path.dirname(uri)) - else + normalizedPath = path.normalize(uri); + {protocol} = url.parse(uri || '') + directoryPath = if protocol? uri + else if not fs.isDirectorySync(normalizedPath) and fs.isDirectorySync(path.dirname(normalizedPath)) + path.dirname(normalizedPath) + else + normalizedPath - # TODO: Stop normalizing the path in pathwatcher Directory. + # TODO: Stop normalizing the path in pathwatcher's Directory. directory = new Directory(directoryPath) - if url.parse(directoryPath).protocol? + if protocol? directory.path = directoryPath if fs.isCaseInsensitive() directory.lowerCasePath = directoryPath.toLowerCase()