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- const https = require ( 'https' ) ;
21const path = require ( 'path' ) ;
32const fs = require ( 'fs' ) ;
43const { spawnSync } = require ( 'child_process' ) ;
54
6- https . get ( 'https://api.github.com/repos/next-theme/hexo-theme-next/releases' , {
7- headers : {
8- 'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36'
9- }
10- } , res => {
11- let data = '' ;
12- res . on ( 'data' , chunk => {
13- data += chunk ;
14- } ) ;
15- res . on ( 'end' , ( ) => {
16- if ( res . statusCode === 200 ) {
17- data = JSON . parse ( data ) ;
18- parse ( data ) ;
19- }
20- } ) ;
21- } ) . on ( 'error' , err => {
22- console . error ( 'Failed to download release messages.' ) ;
23- console . log ( err ) ;
24- } ) ;
25-
265function parse ( data ) {
276 data . sort ( ( a , b ) => {
287 return new Date ( b . created_at ) - new Date ( a . created_at ) ;
@@ -53,3 +32,11 @@ ${body}
5332 stdio : "inherit"
5433 } ) ;
5534}
35+
36+ fetch ( 'https://api.github.com/repos/next-theme/hexo-theme-next/releases' , {
37+ headers : {
38+ 'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36'
39+ }
40+ } )
41+ . then ( res => res . json ( ) )
42+ . then ( parse ) ;
You can’t perform that action at this time.
0 commit comments