validate json instead of a json header, and lots of cleanup

This commit is contained in:
Brian Seymour 2021-05-07 14:22:25 -05:00
parent 0da1cd5867
commit de449c6d56
15 changed files with 272 additions and 269 deletions

View file

@ -9,7 +9,7 @@ const runtimes = [];
class Runtime {
constructor({language, version, aliases, pkgdir, runtime}){
constructor({language, version, aliases, pkgdir, runtime}) {
this.language = language;
this.version = version;
this.aliases = aliases || [];
@ -17,7 +17,7 @@ class Runtime {
this.runtime = runtime;
}
static load_package(package_dir){
static load_package(package_dir) {
let info = JSON.parse(
fss.read_file_sync(path.join(package_dir, 'pkg-info.json'))
);
@ -32,7 +32,7 @@ class Runtime {
);
}
if(provides){
if (provides) {
// Multiple languages in 1 package
provides.forEach(lang => {
runtimes.push(new Runtime({
@ -43,7 +43,7 @@ class Runtime {
runtime: language
}));
});
}else{
} else {
runtimes.push(new Runtime({
language,
version,
@ -53,8 +53,6 @@ class Runtime {
}
logger.debug(`Package ${language}-${version} was loaded`);
}
get compiled() {
@ -108,4 +106,4 @@ module.exports.get_runtime_by_name_and_version = function(runtime, ver){
return runtimes.find(rt => (rt.runtime == runtime || (rt.runtime === undefined && rt.language == runtime)) && semver.satisfies(rt.version, ver));
}
module.exports.load_package = Runtime.load_package;
module.exports.load_package = Runtime.load_package;