mirror of
https://github.com/Redocly/redoc.git
synced 2025-07-04 19:13:03 +03:00
fix: broken paths when budle or serve using cli (#1572)
This commit is contained in:
parent
0a08f121f3
commit
cc04106a68
|
@ -170,9 +170,8 @@ YargsParser.command(
|
||||||
}).argv;
|
}).argv;
|
||||||
|
|
||||||
async function serve(port: number, pathToSpec: string, options: Options = {}) {
|
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);
|
let pageHTML = await getPageHTML(spec, pathToSpec, options);
|
||||||
|
|
||||||
const server = createServer((request, response) => {
|
const server = createServer((request, response) => {
|
||||||
console.time('GET ' + request.url);
|
console.time('GET ' + request.url);
|
||||||
if (request.url === '/redoc.standalone.js') {
|
if (request.url === '/redoc.standalone.js') {
|
||||||
|
@ -218,7 +217,7 @@ async function serve(port: number, pathToSpec: string, options: Options = {}) {
|
||||||
|
|
||||||
const handlePath = async _path => {
|
const handlePath = async _path => {
|
||||||
try {
|
try {
|
||||||
spec = await loadAndBundleSpec(pathToSpec);
|
spec = await loadAndBundleSpec(resolve(pathToSpec));
|
||||||
pageHTML = await getPageHTML(spec, pathToSpec, options);
|
pageHTML = await getPageHTML(spec, pathToSpec, options);
|
||||||
log('Updated successfully');
|
log('Updated successfully');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -245,7 +244,7 @@ async function serve(port: number, pathToSpec: string, options: Options = {}) {
|
||||||
|
|
||||||
async function bundle(pathToSpec, options: Options = {}) {
|
async function bundle(pathToSpec, options: Options = {}) {
|
||||||
const start = Date.now();
|
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 });
|
const pageHTML = await getPageHTML(spec, pathToSpec, { ...options, ssr: true });
|
||||||
|
|
||||||
mkdirp.sync(dirname(options.output!));
|
mkdirp.sync(dirname(options.output!));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user