Skip to content

Commit

Permalink
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
## Unreleased

* Fixes an error in Astro Bookshop, when spreading a prop that is possibly undefined.
* Fixes the Bookshop browser failing to load for Astro sites.

## v3.8.1 (October 5, 2023)

15 changes: 9 additions & 6 deletions javascript-modules/browser/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /usr/bin/env node

import { tmpdir } from "os";
import { mkdtemp } from "fs/promises";
import path from "path";
import Builder from "@bookshop/builder";
import { Command } from "commander";
@@ -11,10 +12,12 @@ import BrowserServer from "./lib/build/browserServer.js";

export const runner = async (options) => {
const bookshopDirs = options.bookshop.map(d => path.join(process.cwd(), d));
const outputFile = options.output ? path.join(process.cwd(), options.output) : null;
const outputFile = options.output
? path.join(process.cwd(), options.output)
: path.join(await mkdtemp(path.join(tmpdir(), 'bookshop-')), 'app.js');
let port = options.port ?? null;
let server = null;
const watch = outputFile ? null : {
const watch = options.output ? null : {
onRebuild(error, result) {
if (error) {
console.error('📚 Renderer rebuild failed:', error)
@@ -24,12 +27,12 @@ export const runner = async (options) => {
},
};

if (outputFile && port) {
if (options.output && port) {
console.error(`Output file and port both specified — one or the other must be provided.`);
process.exit(1);
}

if (!outputFile) {
if (!options.output) {
port = 30775;
}

@@ -53,7 +56,7 @@ export const runner = async (options) => {
exclude: JSON.stringify(options.exclude || []),
onlyEngines: options.onlyEngines,
bookshopDirs: bookshopDirs,
hosted: !!outputFile,
hosted: !!options.output,
}

const output = await Builder(builderOptions);

0 comments on commit c16d3c9

Please sign in to comment.