Skip to contents

Replaces one or more patterns in a dockerignore object with new patterns.

Usage

di_replace(dockerignore, old_pattern, new_pattern)

Arguments

dockerignore

A dockerignore object

old_pattern

Pattern(s) to replace

new_pattern

New pattern(s)

Value

An updated dockerignore object with the specified patterns replaced

Details

This function allows you to replace patterns in a dockerignore object. Three modes of operation are supported:

  1. Replace a single pattern with a single pattern

  2. Replace multiple patterns with a single pattern

  3. Replace multiple patterns with corresponding new patterns (one-to-one)

For the third mode, old_pattern and new_pattern must have the same length.

See also

di_add() for adding patterns & di_remove() for removing patterns

Other dockerignore instruction functions: di_add(), di_remove()

Examples

# Create a dockerignore object and add some patterns
di <- dockerignore() |>
  di_add(c("*.log", "*.tmp", "node_modules/"))

# Replace a single pattern
di <- di_replace(di, "*.log", "logs/")

# Replace multiple patterns with a single pattern
di <- di_replace(di, c("*.tmp", "node_modules/"), "temp/")

# Replace patterns one-to-one
di <- di_replace(di, 
                c("*.log", "*.tmp"), 
                c("logs/*", "temp/*"))