From 0c0a21b030ebf1329448a25d0a043a5c728de6a3 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Mon, 30 May 2022 09:42:03 +0200 Subject: [PATCH] chore: clean verdaccio cache when running locally --- scripts/run-registry.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/run-registry.ts b/scripts/run-registry.ts index 1c4a3807822..313c828afda 100755 --- a/scripts/run-registry.ts +++ b/scripts/run-registry.ts @@ -1,4 +1,5 @@ import { exec } from 'child_process'; +import { remove, pathExists } from 'fs-extra'; import chalk from 'chalk'; import path from 'path'; import program from 'commander'; @@ -176,6 +177,16 @@ const run = async () => { logger.log(`📐 reading version of storybook`); logger.log(`🚛 listing storybook packages`); + + if (!process.env.CI) { + // when running e2e locally, clear cache to avoid EPUBLISHCONFLICT errors + const verdaccioCache = path.resolve(__dirname, '..', '.verdaccio-cache'); + if (await pathExists(verdaccioCache)) { + logger.log(`🗑 cleaning up cache`); + await remove(verdaccioCache); + } + } + logger.log(`🎬 starting verdaccio (this takes ±5 seconds, so be patient)`); const [verdaccioServer, packages, version] = await Promise.all([