From 490890bc15f9972f91e3f35aa4006b2f4f8ce5dd Mon Sep 17 00:00:00 2001 From: shafeeqd959 Date: Mon, 25 May 2026 13:05:44 +0530 Subject: [PATCH] fixed message code resolving --- .talismanrc | 2 ++ .../src/message-handler.ts | 20 +++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.talismanrc b/.talismanrc index 8a25507faf..b1921c3db6 100644 --- a/.talismanrc +++ b/.talismanrc @@ -1,4 +1,6 @@ fileignoreconfig: - filename: pnpm-lock.yaml checksum: eb1a201c2f61d7bceb52d113ae069830ad9c7d590419bbbfa3651982208c8b9b + - filename: packages/contentstack-utilities/src/message-handler.ts + checksum: e7221e8413005b9efe3a230cd91aff130850976addc41c0acb10745a56ec3245 version: '1.0' diff --git a/packages/contentstack-utilities/src/message-handler.ts b/packages/contentstack-utilities/src/message-handler.ts index bbeb78a096..db9e69ea4f 100644 --- a/packages/contentstack-utilities/src/message-handler.ts +++ b/packages/contentstack-utilities/src/message-handler.ts @@ -1,35 +1,29 @@ import fs from 'fs'; import CLIError from './cli-error'; +const STORE_KEY = '__cs_messages__'; + /** * Message handler */ class Messages { - private messages: object; - messageFilePath: any; - - constructor() { - this.messages = {}; - } - init(context) { if (!context.messageFilePath) { return; } try { - this.messages = JSON.parse(fs.readFileSync(context.messageFilePath, 'utf-8')); + const loaded = JSON.parse(fs.readFileSync(context.messageFilePath, 'utf-8')); + (globalThis as any)[STORE_KEY] = { ...(globalThis as any)[STORE_KEY], ...loaded }; } catch (error) { - // create empty messages object if message file is not exist - if (error.code === 'ENOENT') { - this.messages = {}; - } else { + if (error.code !== 'ENOENT') { throw new CLIError(`Error: ${error.message}`); } } } parse(messageKey: string, ...substitutions: Array): string { - const msg = this.messages[messageKey]; + const store = (globalThis as any)[STORE_KEY] || {}; + const msg = store[messageKey]; if (!msg) { return messageKey; }