semver-directory-lookup
Function to lookup the highest available semver notated directory.
const semverDirectoryLookup = ;const directories = await ;
Install
$ npm i -S semver-directory-lookup
Purpose
To lookup in a provided path a directory based on semver and return the available paths that match the searched version.
Use-case
If you wanna retrieve a version based on a request string from a server and want to allow that on request of a major or minor only is possible.
example: the directory /1.31.1
and /1.31.2
are available.
- lookup for
v1.31.1
=> will result in directory1.31.1
- lookup for
v1.31
=> will result in directory1.31.2
- lookup for
v1
=> will result in directory1.31.2
API
semverDirectoryLookup(version[, path])
Parameter | Type | Description |
---|---|---|
version | string | A semantic versioning string. Cleaned (e.g. 1.0.0) or not ( e.g. v1.0.0) does not matter it will map to cleaned version |
path | string | The path the lookup should take care in (default: process.cwd()) |
Contribute
- write code 🤓
npm test
- update changelog under section unreleased
- if test and lint successful and changelog added -> file a PR
License
GPL-2.0 © Willi Eßer