Skip to content

Commit

Permalink
fix(throw on missing stats.json) (#1561)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpchamps authored Mar 13, 2020
1 parent b40e304 commit bd7f5c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 5 additions & 1 deletion packages/subapp-web/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ const utils = {
try {
stats = JSON.parse(Fs.readFileSync(Path.resolve(statsPath)).toString());
} catch (err) {
return {};
throw new Error(
`Couldn't find stats.json at ${Path.resolve(
statsPath
)}. Please ensure environment is set up correctly. (Did you run 'clap dev'?)`
);
}

const assets = {};
Expand Down
7 changes: 4 additions & 3 deletions packages/subapp-web/test/spec/util.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ describe("loadAssetsFromStats", () => {
expect(assets).to.not.have.own.property("manifest");
});

it("should return empty assets if stats.json does not exist", () => {
const assets = loadAssetsFromStats("some path");
expect(assets).be.empty;
it("should throw if stats.json does not exist", () => {
expect(
() => loadAssetsFromStats("some path")
).to.throw();
});
});

Expand Down

0 comments on commit bd7f5c4

Please sign in to comment.