Skip to content

Commit

Permalink
getLaunchedNavies now validates that a navy path is a directory
Browse files Browse the repository at this point in the history
Calls to Navy.safeGetDriver within various methods were throwing
an Error when that navies directory contained a file. One example
being the unintended existence of a .DS_Store file on MacOS.
getLaunchedNavies now filters out all non-directory nodes. Manually
creating an empty directory instead would still surface the problem,
however this would be a seen as an intentional corruption of the navies
directory and the doctor command can be used to resolve this.

Fixes #68
  • Loading branch information
tanuck committed Jul 13, 2017
1 parent 09bb0f2 commit f222723
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/navy/src/navy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import fs from '../util/fs'
import {resolveDriverFromName} from '../driver'
import {resolveConfigProviderFromName} from '../config-provider'
import {normaliseNavyName} from './util'
import {getState, saveState, deleteState, pathToNavys} from './state'
import {getState, saveState, deleteState, pathToNavys, pathToNavy} from './state'
import {getConfig} from '../config'
import {NavyNotInitialisedError, NavyError} from '../errors'
import {loadPlugins} from './plugin-interface'
Expand Down Expand Up @@ -575,7 +575,9 @@ export function getNavy(navyName: ?string): Navy {
export async function getLaunchedNavies(): Promise<Array<Navy>> {
try {
const navyNames = await fs.readdirAsync(pathToNavys())
return navyNames.map(name => getNavy(name))
return navyNames
.filter(node => fs.lstatSync(pathToNavy(node)).isDirectory())
.map(name => getNavy(name))
} catch (ex) {
return []
}
Expand Down

0 comments on commit f222723

Please sign in to comment.