Skip to main content
Coordinate changes beyond a single file: secondary-file transforms, renames, and repo-scoped matrix runs.

Multi-Repo Orchestration

Use multi-repo orchestration when your codemod must coordinate changes across multiple repositories—such as updating shared libraries, enforcing consistency, or applying repo-specific logic. This approach streamlines large-scale migrations and ensures changes are applied uniformly.

Multi-File Transforms

Sometimes a codemod needs to modify multiple files in a coordinated way. For example, renaming a .less file to .css and updating every import that references it. JSSG provides two mechanisms for this:

jssgTransform — Transform Secondary Files

Use jssgTransform() to apply a transform function to another file from within your main transform. The secondary file’s changes are collected and applied atomically alongside the primary file’s changes.
jssgTransform is a no-op in test mode — it returns null without reading or writing files. This means test cases only verify the primary transform. To test secondary transforms, write separate test cases for them.

root.rename() — Rename the Current File

Use root.rename(newPath) to rename the file currently being processed. This is useful for file extension conversions (.js → .ts, .less → .css, .cjs → .mjs).
Rules:
  • Relative paths resolve against the file’s parent directory.
  • Absolute paths are used as-is.
  • The resolved path must stay within the target directory.
  • rename() can only be called once per file.
See the API Reference for the full behavior matrix.