Skip to content

Commit c8f8889

Browse files
committed
Fetch tracers.js from unpkg instead of from github release
1 parent 0fcc12a commit c8f8889

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/tracers/js/JsTracer.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
import path from 'path';
2-
import { download } from 'utils/misc';
32
import { Release, Tracer } from 'tracers/Tracer';
43
import express from 'express';
5-
import { publicDir } from 'config/paths';
64

75
export class JsTracer extends Tracer {
8-
readonly tracerPath: string;
96
readonly workerPath: string;
7+
tagName?: string;
108

119
constructor() {
1210
super('js');
13-
this.tracerPath = path.resolve(publicDir, 'algorithm-visualizer.js');
1411
this.workerPath = path.resolve(__dirname, 'worker.js');
1512
}
1613

17-
build(release: Release) {
14+
async build(release: Release) {
1815
const {tag_name} = release;
19-
return download(`https://github.com/algorithm-visualizer/tracers.js/releases/download/${tag_name}/algorithm-visualizer.js`, this.tracerPath);
16+
this.tagName = tag_name;
2017
}
2118

2219
route(router: express.Router) {
23-
router.get(`/${this.lang}`, (req, res) => res.sendFile(this.tracerPath));
20+
router.get(`/${this.lang}`, (req, res) => {
21+
if (!this.tagName) throw new Error('JsTracer has not been built yet.');
22+
const version = this.tagName.slice(1);
23+
res.redirect(`https://unpkg.com/algorithm-visualizer@${version}/dist/index.umd.js`);
24+
});
2425
router.get(`/${this.lang}/worker`, (req, res) => res.sendFile(this.workerPath));
2526
}
2627
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy