Skip to content

Commit

Permalink
fix: broken paths when budle or serve using cli (#1572)
Browse files Browse the repository at this point in the history
  • Loading branch information
andriyl committed Apr 9, 2021
1 parent 0a08f12 commit cc04106
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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) {
Expand All @@ -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!));
Expand Down

0 comments on commit cc04106

Please sign in to comment.