This repository was archived by the owner on Mar 22, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+
2+ const config = require ( "../config" ) ;
3+ const fse = require ( 'fs-extra' ) ;
4+
5+ fse . removeSync ( config . repoRoot ) ;
6+ fse . mkdirsSync ( config . repoRoot ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ const config = require ( "../config" ) ;
2+ const fse = require ( 'fs-extra' ) ;
3+ const path = require ( 'path' ) ;
4+ const run = require ( '../lib/run' ) ;
5+ const execSync = require ( 'child_process' ) . execSync ;
6+ const Stats = require ( '../lib/stats' ) ;
7+ const debug = require ( 'debug' ) ( 'init' ) ;
8+ const updateRepo = require ( '../lib/updateRepo' ) ;
9+
10+ ( async function ( ) {
11+ for ( let repoName in config . secret . repos ) {
12+ let repoConfig = config . secret . repos [ repoName ] ;
13+
14+ await updateRepo ( repoName ) ;
15+ }
16+
17+ for ( let repoName in config . secret . repos ) {
18+ let repoConfig = config . secret . repos [ repoName ] ;
19+
20+ if ( repoConfig . lang != 'en' ) {
21+ await Stats . instance ( ) . count ( repoName ) ;
22+ }
23+ }
24+
25+ } ) ( ) . catch ( console . error ) ;
Original file line number Diff line number Diff line change 11const crypto = require ( 'crypto' ) ;
22const config = require ( '../config' ) ;
33const debug = require ( 'debug' ) ( 'handlers:hook' ) ;
4- const onUpdateHook = require ( '../lib/onUpdateHook ' ) ;
4+ const updateRepo = require ( '../lib/updateRepo ' ) ;
55
66exports . post = async function ( ctx ) {
77
@@ -56,6 +56,8 @@ exports.post = async function(ctx) {
5656 ctx . body = { ok : true } ;
5757
5858 // don't wait for it! (async)
59- onUpdateHook ( ctx . request . body ) ;
59+ await updateRepo ( ctx . request . body . repository . name ) ;
60+
61+ await Stats . instance ( ) . count ( ctx . request . body . repository . name ) ;
6062
6163} ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+
2+ const debug = require ( 'debug' ) ( 'run' ) ;
3+ const exec = require ( 'mz/child_process' ) . exec ;
4+
5+ module . exports = async function run ( cmd , options = { } ) {
6+ if ( ! options . encoding ) {
7+ options . encoding = 'utf-8' ;
8+ }
9+
10+ debug ( cmd , options ) ;
11+ let result = await exec ( cmd , options ) ;
12+ debug ( result ) ;
13+
14+ return result ;
15+ } ;
Original file line number Diff line number Diff line change 1+ const config = require ( "../config" ) ;
2+ const path = require ( "path" ) ;
3+ const run = require ( './run' ) ;
4+ const fs = require ( 'fs' ) ;
5+
6+ module . exports = async function ( repoName ) {
7+ let repoDir = path . join ( config . repoRoot , path . basename ( repoName ) ) ;
8+
9+ let repoConfig = config . secret . repos [ repoName ] ;
10+
11+ let branch = repoConfig . branch || 'master' ;
12+
13+ if ( fs . existsSync ( repoDir ) ) {
14+
15+ await run ( `git fetch origin` , { cwd : repoDir } ) ;
16+
17+ } else {
18+
19+ await run ( `git clone --depth 1 https://github.com/${ repoName } .git "${ repoDir } "` ) ;
20+
21+ }
22+
23+ await run ( `git checkout -f origin/${ branch } ` , { cwd : repoDir } ) ;
24+
25+ } ;
26+
27+
You can’t perform that action at this time.
0 commit comments