Skip to content

Commit

Permalink
Don't log missing server dir error on first run
Browse files Browse the repository at this point in the history
  • Loading branch information
pimterry committed Jan 15, 2021
1 parent 04e8263 commit 0f0a91c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,13 @@ if (!amMainInstance) {
const serverUpdatesPath = process.env.OCLIF_CLIENT_HOME ||
path.join(oclifDataPath, 'client');

const serverPaths = await fs.readdir(serverUpdatesPath);
const serverPaths = await fs.readdir(serverUpdatesPath)
// Don't error if this path doesn't exist - that's normal at first
.catch((e) => {
if (e.code === 'ENOENT') {
return [] as string[];
} else throw e;
});

if (serverPaths.some((filename) =>
!semver.valid(filename.replace(/\.partial\.\d+$/, '')) &&
Expand All @@ -299,7 +305,7 @@ if (!amMainInstance) {

// If the bundled server is newer than all installed server versions, then
// delete all the installed server versions entirely before we start.
if (!serverPaths.some((serverPath) => {
if (serverPaths.length && !serverPaths.some((serverPath) => {
try {
return semver.gt(serverPath, BUNDLED_SERVER_VERSION)
} catch (e) {
Expand Down

0 comments on commit 0f0a91c

Please sign in to comment.