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

view: Error on missing build files #1608

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 7 additions & 4 deletions cli/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,14 @@ const getAuspiceBuild = () => {
const cwd = path.resolve(process.cwd());
const sourceDir = path.resolve(__dirname, "..");
if (
cwd !== sourceDir &&
fs.existsSync(path.join(cwd, "index.html")) &&
fs.existsSync(path.join(cwd, "dist")) &&
fs.readdirSync(path.join(cwd, "dist")).filter((fn) => fn.match(/^auspice.bundle.[a-z0-9]+.js$/)).length === 1
!fs.existsSync(path.join(cwd, "dist")) ||
!fs.existsSync(path.join(cwd, "dist/index.html")) ||
!fs.readdirSync(path.join(cwd, "dist")).filter((fn) => fn.match(/^auspice.bundle.[a-z0-9]+.js$/)).length === 1
) {
console.log(chalk.redBright(`ERROR: Auspice build files not found under ${cwd}. Did you run \`auspice build\` in this directory?`));
Copy link
Member Author

@victorlin victorlin Dec 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bdfe751:

When running from an external project, this prevents falling back to running from build files in Auspice's root directory, which is often unintentional.

As mentioned in #1606 (comment), this behavior is actually intentional for anyone using npm install --global auspice. Thinking more on this now.

process.exit(1);
}
if (cwd !== sourceDir) {
return {
message: "Serving the auspice build which exists in this directory.",
baseDir: cwd,
Expand Down