From cc04106a68b2d69638385ac796f666e7ee197301 Mon Sep 17 00:00:00 2001 From: Andriy Leliv Date: Fri, 9 Apr 2021 11:10:49 +0300 Subject: [PATCH] fix: broken paths when budle or serve using cli (#1572) --- cli/index.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cli/index.ts b/cli/index.ts index ef01a101..ef7f1135 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -170,9 +170,8 @@ YargsParser.command( }).argv; async function serve(port: number, pathToSpec: string, options: Options = {}) { - let spec = await loadAndBundleSpec(pathToSpec); + let spec = await loadAndBundleSpec(existsSync(pathToSpec) ? resolve(pathToSpec) : pathToSpec); let pageHTML = await getPageHTML(spec, pathToSpec, options); - const server = createServer((request, response) => { console.time('GET ' + request.url); if (request.url === '/redoc.standalone.js') { @@ -218,7 +217,7 @@ async function serve(port: number, pathToSpec: string, options: Options = {}) { const handlePath = async _path => { try { - spec = await loadAndBundleSpec(pathToSpec); + spec = await loadAndBundleSpec(resolve(pathToSpec)); pageHTML = await getPageHTML(spec, pathToSpec, options); log('Updated successfully'); } catch (e) { @@ -245,7 +244,7 @@ async function serve(port: number, pathToSpec: string, options: Options = {}) { async function bundle(pathToSpec, options: Options = {}) { const start = Date.now(); - const spec = await loadAndBundleSpec(pathToSpec); + const spec = await loadAndBundleSpec(existsSync(pathToSpec) ? resolve(pathToSpec) : pathToSpec); const pageHTML = await getPageHTML(spec, pathToSpec, { ...options, ssr: true }); mkdirp.sync(dirname(options.output!));