Skip to content

Commit 0f0a91c

Browse files
committed
Don't log missing server dir error on first run
1 parent 04e8263 commit 0f0a91c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,13 @@ if (!amMainInstance) {
281281
const serverUpdatesPath = process.env.OCLIF_CLIENT_HOME ||
282282
path.join(oclifDataPath, 'client');
283283

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

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

300306
// If the bundled server is newer than all installed server versions, then
301307
// delete all the installed server versions entirely before we start.
302-
if (!serverPaths.some((serverPath) => {
308+
if (serverPaths.length && !serverPaths.some((serverPath) => {
303309
try {
304310
return semver.gt(serverPath, BUNDLED_SERVER_VERSION)
305311
} catch (e) {

0 commit comments

Comments
 (0)