Overview
Assuming a distribution (dist) tag is included in package version or release tag (e.g 3.13.98-dev.640
, [email protected]
), dtag
helps maintainers lookup and interpolate distribution tags.
Lookups
Basic
import dtag from '@flex-development/dtag'
/**
* @file Examples - Lookup
* @module dtag/docs/examples/lookup
*/
dtag({ version: '3.13.98-dev.640' }) // => 'dev'
Interpolation
import dtag from '@flex-development/dtag'
/**
* @file Examples - Interpolated Lookup
* @module dtag/docs/examples/lookup-map
*/
dtag({ map: { rc: 'next' }, version: 'v3.0.0-rc' }) // => 'next'
Monorepos
import dtag from '@flex-development/dtag'
/**
* @file Examples - Lookup Monorepo
* @module dtag/docs/examples/lookup-monorepo
*/
const tagPrefix: string = 'foo@'
dtag({ tagPrefix, version: '[email protected]' }) // => 'beta'
dtag({
map: { rc: 'next' },
tagPrefix,
version: '[email protected]'
}) // => 'beta'
Options
/**
* `dtag` options.
*/
export interface DistTagOptions {
/**
* Prerelease delimiter (e.g `-` before `alpha` in `[email protected]`).
*
* @default '-'
*/
delimiter?: string
/**
* Distribution (dist) tag map. If a dist tag is found in `version` and `map`
* is a non-empty object, the tag returned will be plucked from `map`.
*
* @default {}
*/
map?: Record<string, string>
/**
* Skip distribution tag lookup.
*/
skip?: boolean
/**
* Git tag prefix.
*
* @default 'v'
*/
tagPrefix?: string
/**
* Package version (with or without `tagPrefix`).
*
* @default null
*/
version?: any
}