File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ import path from 'path' ;
2
+ import { Release , Tracer } from 'tracers/Tracer' ;
3
+ import express from 'express' ;
4
+ import { GitHubApi } from 'utils/apis' ;
5
+
6
+ export class JuliaTracer extends Tracer {
7
+ readonly workerPath : string ;
8
+ tagName ?: string ;
9
+
10
+ constructor ( ) {
11
+ super ( 'julia' ) ;
12
+ this . workerPath = path . resolve ( __dirname , 'worker.js' ) ;
13
+ }
14
+
15
+ async build ( release : Release ) {
16
+ const { tag_name} = release ;
17
+ this . tagName = tag_name ;
18
+ }
19
+
20
+ route ( router : express . Router ) {
21
+ router . get ( `/${ this . lang } ` , ( req , res ) => {
22
+ if ( ! this . tagName ) throw new Error ( 'JuliaTracer has not been built yet.' ) ;
23
+ const version = this . tagName . slice ( 1 ) ;
24
+ res . redirect ( `https://unpkg.com/algorithm-visualizer@${ version } /dist/algorithm-visualizer.umd.js` ) ;
25
+ } ) ;
26
+ router . get ( `/${ this . lang } /worker` , ( req , res ) => res . sendFile ( this . workerPath ) ) ;
27
+ }
28
+
29
+ async update ( release ?: Release ) {
30
+ if ( release ) {
31
+ return this . build ( release ) ;
32
+ }
33
+ const { data} = await GitHubApi . getLatestRelease ( 'likewu' , `tracers.${ this . lang } ` ) ;
34
+ return this . build ( data ) ;
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments