mirror of
https://github.com/engineer-man/piston.git
synced 2025-04-20 20:16:26 +02:00
validate json instead of a json header, and lots of cleanup
This commit is contained in:
parent
0da1cd5867
commit
de449c6d56
15 changed files with 272 additions and 269 deletions
|
@ -165,14 +165,14 @@ class Package {
|
|||
|
||||
static async get_package_list() {
|
||||
const repo_content = await fetch(config.repo_url).then(x => x.text());
|
||||
|
||||
|
||||
const entries = repo_content
|
||||
.split('\n')
|
||||
.filter(x => x.length > 0);
|
||||
|
||||
|
||||
return entries.map(line => {
|
||||
const [ language, version, checksum, download ] = line.split(',', 4);
|
||||
|
||||
|
||||
return new Package({
|
||||
language,
|
||||
version,
|
||||
|
@ -181,17 +181,17 @@ class Package {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
static async get_package (lang, version) {
|
||||
|
||||
static async get_package(lang, version) {
|
||||
const packages = await Package.get_package_list();
|
||||
|
||||
|
||||
const candidates = packages
|
||||
.filter(pkg => {
|
||||
return pkg.language == lang && semver.satisfies(pkg.version, version)
|
||||
});
|
||||
|
||||
|
||||
candidates.sort((a, b) => semver.rcompare(a.version, b.version));
|
||||
|
||||
|
||||
return candidates[0] || null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue