Developer Preview — This project is in active development. APIs may change. Provide feedback
Skip to content

@salesforce/b2c-tooling-sdk / operations/logs / createPathNormalizer

Function: createPathNormalizer()

createPathNormalizer(options): (message) => string | undefined

Defined in: packages/b2c-tooling-sdk/src/operations/logs/path-normalizer.ts:121

Creates a path normalizer function for converting remote cartridge paths to local paths in log messages.

Supports two modes:

  1. Cartridge mappings (precise): Uses discovered cartridges to map each cartridge name to its actual local path. Best for projects with cartridges in different locations.
  2. Cartridge path (simple): Prefixes all paths with a base directory. Best when all cartridges are in a single directory.

Parameters

options

PathNormalizerOptions

Normalizer options

Returns

(message) => string | undefined

Function that normalizes paths in a message string, or undefined if no options provided

Example

typescript
// Using discovered cartridges (recommended)
const cartridges = findCartridges('./my-project');
const normalize = createPathNormalizer({ cartridges });

// Using simple cartridge path
const normalize = createPathNormalizer({ cartridgePath: './cartridges' });

// Input: "(app_storefront/cartridge/controllers/Home.js:45)"
// Output: "(./cartridges/app_storefront/cartridge/controllers/Home.js:45)"
const normalized = normalize(logMessage);

Released under the Apache-2.0 License.