Sass-versioning
mixins
versioning-add
@mixin versioning-add($name, $version, $dependencies) { ... }
Description
Logic for adding versioning to the global list $versioning-glob-dependencies
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$name | Name of the module adding this dependency | String | — none |
$version | Version of the module adding this dependency | String | — none |
$dependencies | Dependencies of this module | List | — none |
Example
$name: "accordion";
$version: "1.0.0";
$dependencies: (
("core", "2.0.0"),
("grid", "1.0.0"),
);
@include versioning-add( $name, $version, $dependencies );
Output
The variable $versioning-glob-dependencies
will be populated with the items that have been passed
versioning-remove
@mixin versioning-remove($name) { ... }
Description
Logic for removing a single dependency from our list if that dependency e.g. doesn’t have a sass presence
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$name | Name of the module adding this dependency | String | — none |
Example
@include versioning-remove( 'animation' );
Output
The variable $versioning-glob-dependencies
will be stripped off our dependency
versioning-check
@mixin versioning-check() { ... }
Description
Testing if all dependencies inside $versioning-glob-dependencies
are satisfied
Parameters
None.
Example
@include versioning-check();
Sass-semver
functions
clean
@function clean($version) { ... }
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$version | — none | String | — none |
Returns
String
Example
$version: clean('v1.2.3');
-> '1.2.3'
cmp
@function cmp($v1, $comparator, $v2) { ... }
Description
Pass in a comparison string, and it will call the corresponding function.
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$v1 | — none | String | — none |
$comparator | — none | String | — none |
$v2 | — none | String | — none |
Returns
Boolean
Example
$cmp: cmp('1.2.3', '==', '0.1.2');
-> false
$cmp: cmp('1.2.3', '===', '0.1.2');
-> false
$cmp: cmp('1.2.3', '>', '0.1.2');
-> true
$cmp: cmp('1.2.3', '>=', '0.1.2');
-> true
$cmp: cmp('1.2.3', '!=', '0.1.2');
-> true
$cmp: cmp('1.2.3', '!==', '0.1.2');
-> true
$cmp: cmp('1.2.3', '<', '0.1.2');
-> false
$cmp: cmp('1.2.3', '<=', '0.1.2');
-> false
eq
@function eq($v1, $v2) { ... }
Description
Return whether the first version is equal to the second
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$v1 | — none | String | — none |
$v2 | — none | String | — none |
Returns
Boolean
Example
$eq: eq('1.2.3', '3.2.1');
-> false
$eq: eq('1.2.3', '1.2.3');
-> true
$eq: eq('1.2.3', '0.1.2');
-> false
gt
@function gt($v1, $v2) { ... }
Description
Return whether the first version is greater than the second
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$v1 | — none | String | — none |
$v2 | — none | String | — none |
Returns
Boolean
Example
$gt: gt('1.2.3', '3.2.1');
-> false
$gt: gt('1.2.3', '1.2.3');
-> false
$gt: gt('1.2.3', '0.1.2');
-> true
gte
@function gte($v1, $v2) { ... }
Description
Return whether the first version is greater than or equal to the second
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$v1 | — none | String | — none |
$v2 | — none | String | — none |
Returns
Boolean
Example
$gte: gte('1.2.3', '3.2.1');
-> false
$gte: gte('1.2.3', '1.2.3');
-> true
$gte: gte('1.2.3', '0.1.2');
-> true
inc
@function inc($version, $release) { ... }
Description
Return the version incremented by the release type (major, minor, patch, prerelease)
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$version | — none | String | — none |
$release | Type of release to bump (major, minor, patch, prerelease) | String | — none |
Returns
String
Example
$version: inc('1.2.3', 'major');
-> '2.0.0'
$version: inc('1.2.3', 'minor');
-> '1.3.0'
$version: inc('1.2.3', 'patch');
-> '1.2.4'
$version: inc('1.2.3', 'prerelease');
-> '1.2.3-beta.0'
$version: inc('1.2.3', 'prerelease', 'foobar');
-> '1.2.3-foobar.0'
$version: inc('1.2.3-foobar.0', 'prerelease');
-> '1.2.3-foobar.1'
$version: inc('1.2.3', 'premajor');
-> '2.0.0-beta.0'
$version: inc('1.2.3', 'preminor');
-> '1.3.0-beta.0'
$version: inc('1.2.3', 'prepatch');
-> '1.2.4-beta.0'
lt
@function lt($v1, $v2) { ... }
Description
Return whether the first version is lesser than the second
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$v1 | — none | String | — none |
$v2 | — none | String | — none |
Returns
Boolean
Example
$lt: lt('1.2.3', '3.2.1');
-> true
$lt: lt('1.2.3', '1.2.3');
-> false
$lt: lt('1.2.3', '0.1.2');
-> false
lte
@function lte($v1, $v2) { ... }
Description
Return whether the first version is lesser than or equal to the second
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$v1 | — none | String | — none |
$v2 | — none | String | — none |
Returns
Boolean
Example
$lte: lte('1.2.3', '3.2.1');
-> true
$lte: lte('1.2.3', '1.2.3');
-> true
$lte: lte('1.2.3', '0.1.2');
-> false
major
@function major($version) { ... }
Description
Return the major version number
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$version | — none | String | — none |
Returns
Number
Example
$major: major('1.2.3');
-> 1
minor
@function minor($version) { ... }
Description
Return the minor version number
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$version | — none | String | — none |
Returns
Number
Example
$minor: minor('1.2.3');
-> 2
neq
@function neq($v1, $v2) { ... }
Description
Return whether the first version is not equal to the second
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$v1 | — none | String | — none |
$v2 | — none | String | — none |
Returns
Boolean
Example
$eq: eq('1.2.3', '3.2.1');
-> true
$eq: eq('1.2.3', '1.2.3');
-> false
$eq: eq('1.2.3', '0.1.2');
-> true
patch
@function patch($version) { ... }
Description
Return the patch version number
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$version | — none | String | — none |
Returns
Number
Example
$patch: patch('1.2.3');
-> 3
valid
@function valid($version) { ... }
Description
Return whether $version is valid SemVer
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$version | — none | String | — none |
Returns
Boolean
Example
$valid: valid('1.2.3');
-> true
$not-valid: valid('a.b.c');
-> false
[private] _first-index
@function _first-index($string, $direction: 'left') { ... }
Description
Find first char which is not a space
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$string | String | String | — none |
$direction | Either | String | 'left' |
Returns
Number
[private] _format
@function _format($major, $minor, $patch, $pre-name: '', $pre-number: -1) { ... }
Description
Format a version based on its components
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$major | — none | Number | — none |
$minor | — none | Number | — none |
$patch | — none | Number | — none |
$pre-name | — none | String | '' |
$pre-number | — none | Number | -1 |
Returns
String
[private] _prerelease
@function _prerelease($version) { ... }
Description
Parse the prerelease of $version
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$version | — none | String | — none |
Returns
Map
Example
$prerelease: _prerelease('1.2.3');
-> ( 'name': null, 'number': -1 )
$prerelease: _prerelease('1.2.3-alpha.0');
-> ( 'name': 'alpha', 'number': 0 )
[private] _str-last-index
@function _str-last-index($string, $needle) { ... }
Description
Return last index of $needle
in $string
.
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$string | string to search in | String | — none |
$needle | substring to search for | String | — none |
Returns
Number
[private] _trim
@function _trim($string) { ... }
Description
Trim $string
Parameters
parameter Name | parameter Description | parameter Type | parameter Default value |
---|---|---|---|
$string | String to trim | String | — none |
Returns
String