From 175e63f7ec819f9f486ccbfeb2327d3fddda900f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Mon, 11 Apr 2022 12:31:14 +0200 Subject: [PATCH] :zap: Switch to async check --- packages/cli/src/Server.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 22be162689a5a..14aff9569f762 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -30,7 +30,7 @@ /* eslint-disable no-await-in-loop */ import express from 'express'; -import { readFileSync, existsSync } from 'fs'; +import { readFileSync, promises } from 'fs'; import { readFile } from 'fs/promises'; import _, { cloneDeep } from 'lodash'; import { dirname as pathDirname, join as pathJoin, resolve as pathResolve } from 'path'; @@ -1504,7 +1504,11 @@ class App { const packagesPath = pathJoin(__dirname, '..', '..', '..'); const headersPath = pathJoin(packagesPath, 'nodes-base', 'dist', 'nodes', 'headers'); - if (!existsSync(`${headersPath}.js`)) return; + try { + await promises.access(`${headersPath}.js`); + } catch (_) { + return; // no headers available + } try { return require(headersPath);