Files
shields/services/conan/conan-version-helpers.js
Jacob Bandes-Storch 814aa30da4 Add [Conan] version service (#7460)
* Add [Conan] version service

* Rework to use conan-center-index GitHub repo

* Conditional mock based on presence of github token

* Refactor yaml parsing into a helper function, move tests to .spec.js

* remove custom version parsing

* improve test data

* updates from review

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2022-03-01 06:08:45 +00:00

22 lines
568 B
JavaScript

import yaml from 'js-yaml'
import { NotFound, InvalidResponse } from '../index.js'
import { latest } from '../version.js'
export function parseLatestVersionFromConfig(configYaml) {
let versions
try {
const config = yaml.load(configYaml)
versions = Object.keys(config.versions)
} catch (err) {
throw new InvalidResponse({
prettyMessage: 'invalid config.yml',
underlyingError: err,
})
}
const version = latest(versions)
if (version == null) {
throw new NotFound({ prettyMessage: 'no versions found' })
}
return version
}