Skip to content

Commit

Permalink
update ephemeral-packages wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlatwe committed Mar 4, 2021
1 parent e551be4 commit 489807e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions wiki/pages/Ephemeral-Packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,19 @@ to the [resolve](Package-Commands#resolve) object. You would typically use the

# in package.py
def commands()
if intersects(ephemerals.get('enable_tracking', '0'), '1'):
if intersects(ephemerals.get_range('enable_tracking', '0'), '1'):
env.TRACKING_ENABLED = 1

In this example, the given package would set the `TRACKING_ENABLED` environment
variable if an ephemeral such as `.enable_tracking-1` (or `.enable_tracking-1.2+`
etc) is present in the resolve. Note that the leading `.` is implied and not
included when querying the `ephemerals` object.

> [[media/icons/warning.png]] Since `ephemerals` is a dict-like object, so it has
> a `get` function which will return a full request string if key exists. Hence,
> the default value should also be a full request string, not just a version range
> string like `'0'` in `get_range`. Or `intersects` may not work as expect.
## Ephemeral Use Cases

Why would you want to request packages that don't exist? There are two main use
Expand All @@ -101,7 +106,7 @@ to packages in a resolve. For example, consider the following package definition
name = 'bah'

def commands():
if intersects(ephemerals.get('bah.cli', '1'), '1'):
if intersects(ephemerals.get_range('bah.cli', '1'), '1'):
env.PATH.append('{root}/bin')

This package will disable its command line tools if an ephemeral like `.bah.cli-0`
Expand All @@ -120,7 +125,7 @@ we introduce a `.cli` ephemeral that acts as a global whitelist:
name = 'bah'

def commands():
if intersects(ephemerals.get('cli', ''), 'bah'):
if intersects(ephemerals.get_range('cli', ''), 'bah'):
env.PATH.append('{root}/bin')

Here, all packages' cli will be enabled if `.cli` is not specified, but if it is
Expand Down

0 comments on commit 489807e

Please sign in to comment.