Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: broken paths when budle or serve using cli #1572

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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