@@ -14,6 +14,8 @@ import { errorHandlerMiddleware, frontendMiddleware, redirectMiddleware } from '
14
14
import { execute , issueHttpsCertificate , pull } from 'utils/misc' ;
15
15
import { frontendBuildDir , frontendBuiltDir , frontendDir , rootDir } from 'config/paths' ;
16
16
17
+ import fs from 'fs-extra' ;
18
+
17
19
const Webhook = require ( 'express-github-webhook' ) ;
18
20
19
21
export default class Server {
@@ -91,7 +93,23 @@ export default class Server {
91
93
} ;
92
94
93
95
async updateFrontend ( commit ?: string ) {
94
- await pull ( frontendDir , 'algorithm-visualizer' , commit ) ;
96
+ if ( fs . pathExistsSync ( frontendDir ) ) {
97
+ await execute ( `git fetch` , {
98
+ cwd : frontendDir ,
99
+ stdout : process . stdout ,
100
+ stderr : process . stderr ,
101
+ } ) ;
102
+ } else {
103
+ await execute ( `git clone https://github.com/likewu/algorithm-visualizer.git ${ frontendDir } ` , {
104
+ stdout : process . stdout ,
105
+ stderr : process . stderr ,
106
+ } ) ;
107
+ }
108
+ await execute ( `git reset --hard origin/master` , {
109
+ cwd : frontendDir ,
110
+ stdout : process . stdout ,
111
+ stderr : process . stderr ,
112
+ } ) ;
95
113
await execute ( [
96
114
'npm install' ,
97
115
'npm run build' ,
0 commit comments