From 409b540b8082bc9a00afedbc3e714e93d78b68b8 Mon Sep 17 00:00:00 2001 From: SijieWang Date: Tue, 14 Nov 2023 16:31:43 +0800 Subject: [PATCH] [Bug] Fix the error that occurs when executing clear on an empty warehouse (#16507) Fix the error that occurs when executing clear on an empty warehouse --- scripts/clear-cache.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/clear-cache.js b/scripts/clear-cache.js index 09e3edc9ff..c4a3d054eb 100644 --- a/scripts/clear-cache.js +++ b/scripts/clear-cache.js @@ -1,7 +1,13 @@ const fs = require('fs'); const path = require('path'); const readline = require('readline'); -const { magenta } = require('chalk'); + +let magenta; +try { + magenta = require('chalk').magenta; +} catch (error) { + magenta = (str) => str; +} const prefix = ''.padStart(20, '='); console.log(magenta(`${prefix} Clear cache ${prefix}`));