1
- const fs = require ( 'fs-extra' ) ; // Reading README.md
2
- const path = require ( 'path' ) ; // Get the correct path for README.md
3
- const fetch = require ( 'node-fetch' ) ; // Make calls to Reddit from Node.js
4
- const qs = require ( 'qs' ) ; // Properly build a query for node-fetch POST
5
- const moment = require ( 'moment' ) ; // Time-related functions
6
-
7
- //#region constants
1
+ const fs = require ( 'fs-extra' ) ;
2
+ const path = require ( 'path' ) ;
3
+ const fetch = require ( 'node-fetch' ) ;
4
+ const qs = require ( 'qs' ) ;
5
+ const { DateTime } = require ( 'luxon' ) ;
8
6
9
7
// REDDIT_: For authentication with Reddit API. Oauth MUST be used. ID and Secret come from a "script" app type.
10
8
const REDDIT_USER = process . env . REDDIT_USER || 'username' ;
@@ -29,15 +27,12 @@ const ENDPOINTS = {
29
27
30
28
// Helps POST data be submitted properly
31
29
const CONTENT_TYPE = 'application/x-www-form-urlencoded' ;
32
- //#endregion
33
30
34
31
// Update the wiki
35
32
Promise . all ( [ getLastRevision ( ) , getToken ( ) ] )
36
33
. then ( ( [ lastId , token ] ) => putWiki ( lastId , token ) )
37
34
. catch ( ( err ) => ( console . error ( err ) , process . exit ( 1 ) ) ) ;
38
35
39
- //#region functions
40
-
41
36
/**
42
37
* Get the last revision ID on the Wiki. Required otherwise editing the wiki fails
43
38
*/
@@ -96,12 +91,11 @@ function putWiki(lastId, token) {
96
91
*/
97
92
function fixContent ( content ) {
98
93
// Fix updated timestamp
99
- content = content . replace ( / \! \[ U p d a t e d \] ( .* ?) s q u a r e \) / g, `#### Updated: ${ moment ( ) . format ( 'MMMM Do YYYY ' ) } ` ) ;
94
+ content = content . replace ( / \! \[ U p d a t e d \] ( .* ?) s q u a r e \) / g, `#### Updated: ${ DateTime . now ( ) . toFormat ( 'MMMM dd, yyyy ' ) } ` ) ;
100
95
101
96
// Fix published timestamps
102
97
content = content . replace ( / \! \[ P u b l i s h e d \] \( h t t p s \: \/ \/ i m g \. s h i e l d s \. i o \/ b a d g e \/ / g, '**' ) ;
103
98
content = content . replace ( / - i n f o r m a t i o n a l \? s t y l e = f l a t - s q u a r e \) / g, '**' ) ;
104
99
105
100
return content ;
106
101
} // * If this is highlighted weirdly, it's because of the 'updated timestamp' regex, don't worry about it
107
- //#endregion
0 commit comments