Skip to content

Commit

Permalink
fix: ensure public cache directory exist before writing files in it
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetanmaisse committed Nov 24, 2020
1 parent 68ee04d commit cbf8f4c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/core/src/server/build-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ const cache = Cache({
});

const writeStats = async (name: string, stats: Stats) => {
await fs.writeFile(
resolvePathInStorybookCache(`public/${name}-stats.json`),
JSON.stringify(stats.toJson(), null, 2),
'utf8'
);
const statsFilePath = resolvePathInStorybookCache(`public/${name}-stats.json`);
await fs.ensureFile(statsFilePath);
await fs.writeFile(statsFilePath, JSON.stringify(stats.toJson(), null, 2), 'utf8');
};

const getFreePort = (port: number) =>
Expand Down

0 comments on commit cbf8f4c

Please sign in to comment.