Naming refactor, remove id getter and use index
This commit is contained in:
parent
286fb57415
commit
d5392eafb8
|
@ -277,13 +277,13 @@ router.post('/execute', async (req, res) => {
|
|||
});
|
||||
|
||||
router.get('/runtimes', (req, res) => {
|
||||
const runtimes = runtime.map(rt => {
|
||||
const runtimes = runtime.map((rt, index) => {
|
||||
return {
|
||||
language: rt.language,
|
||||
version: rt.version.raw,
|
||||
aliases: rt.aliases,
|
||||
runtime: rt.runtime,
|
||||
id: rt.id,
|
||||
id: index,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
@ -39,10 +39,14 @@ expressWs(app);
|
|||
|
||||
logger.info('Loading packages');
|
||||
|
||||
const runtimes_data = cp.execSync(`nix eval --json ${config.flake_path}#pistonRuntimeSets.${config.runtime_set} --apply builtins.attrNames`).toString();
|
||||
const runtimes = JSON.parse(runtimes_data);
|
||||
|
||||
runtimes.for_each(pkg => runtime.load_runtime(pkg));
|
||||
const runtimes_data = cp
|
||||
.execSync(
|
||||
`nix eval --json ${config.flake_path}#pistonRuntimeSets.${config.runtime_set} --apply builtins.attrNames`
|
||||
)
|
||||
.toString();
|
||||
const language_names = JSON.parse(runtimes_data);
|
||||
|
||||
language_names.for_each(language_name => runtime.load_runtime(language_name));
|
||||
|
||||
logger.info('Starting API Server');
|
||||
logger.debug('Constructing Express App');
|
||||
|
|
|
@ -120,9 +120,9 @@ class Runtime {
|
|||
logger.debug(`Finished ensuring ${this} is installed`);
|
||||
}
|
||||
|
||||
static load_runtime(flake_key) {
|
||||
logger.info(`Loading ${flake_key}`);
|
||||
const flake_path = `${config.flake_path}#pistonRuntimeSets.${config.runtime_set}.${flake_key}`;
|
||||
static load_runtime(language_name) {
|
||||
logger.info(`Loading ${language_name}`);
|
||||
const flake_path = `${config.flake_path}#pistonRuntimeSets.${config.runtime_set}.${language_name}`;
|
||||
const metadata_command = `nix eval --json ${flake_path}.metadata`;
|
||||
const metadata = JSON.parse(cp.execSync(metadata_command));
|
||||
|
||||
|
@ -139,17 +139,13 @@ class Runtime {
|
|||
|
||||
runtimes.push(this_runtime);
|
||||
|
||||
logger.debug(`Package ${flake_key} was loaded`);
|
||||
logger.debug(`Package ${language_name} was loaded`);
|
||||
}
|
||||
|
||||
get compiled() {
|
||||
return this.compile !== null;
|
||||
}
|
||||
|
||||
get id() {
|
||||
return runtimes.indexOf(this);
|
||||
}
|
||||
|
||||
toString() {
|
||||
return `${this.language}-${this.version}`;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue