in src/models/workflow-listing/index.js [45:84]
async postprocess(value) {
const wdlRegExp = /^(.+)\.wdl$/i;
const filterWDL = (e) => {
if (e.type === FILE) {
return !!wdlRegExp.exec(e.name);
}
return false;
};
await routes.fetchIfNeededOrWait();
const mapPath = e => ({
...e,
path: this.path ? `${this.path}/${e.name}` : e.name,
});
const mapDownloadUrl = e => ({
...e,
downloadUrl: generateUrl(e.path, e.type === DIRECTORY),
});
const mapWDL = (e, index, array) => {
if (e.type === FILE) {
const exec = wdlRegExp.exec(e.name);
if (exec) {
const wdlInputsRegExp = new RegExp(`${exec[1]}\\.inputs\\.json`, 'i');
const readmeRegExp = new RegExp(`${exec[1]}\\.readme\\.md`, 'i');
const [inputs] = array.filter(i => wdlInputsRegExp.test(i.name));
const [readme] = array.filter(i => readmeRegExp.test(i.name));
return {
...e,
inputs,
readme,
};
}
}
return e;
};
return (await super.postprocess(value))
.map(mapPath)
.map(mapDownloadUrl)
.map(mapWDL)
.filter(e => e.type === DIRECTORY || filterWDL(e));
}