Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit a575ddb

Browse files
author
Josh Moore
authored
Merge pull request #505 from tycrek/update-node
2 parents 503634a + 5a3077a commit a575ddb

File tree

4 files changed

+103
-187
lines changed

4 files changed

+103
-187
lines changed

_build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
const { EOL } = require('os');
44
const path = require('path');
55
const fs = require('fs-extra');
6-
const moment = require('moment');
6+
const { DateTime } = require('luxon');
77
const YAML = require('yaml');
88

99
const BUILD_SECTION = {
10-
header: () => readFile('md/_header.md').replace('{{DATE}}', moment().format('MMMM Do YYYY').replace(/ /g, '%20')),
10+
header: () => readFile('md/_header.md').replace('{{DATE}}', DateTime.now().toFormat('MMMM dd, yyyy').replace(/ /g, '%20')),
1111
index: () => readFile('md/_index.md'),
1212
contributing: () => readFile('md/_contributing.md'),
1313
browserExtensions: () => generateBrowserExtensions(),

_wiki.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
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');
86

97
// REDDIT_: For authentication with Reddit API. Oauth MUST be used. ID and Secret come from a "script" app type.
108
const REDDIT_USER = process.env.REDDIT_USER || 'username';
@@ -29,15 +27,12 @@ const ENDPOINTS = {
2927

3028
// Helps POST data be submitted properly
3129
const CONTENT_TYPE = 'application/x-www-form-urlencoded';
32-
//#endregion
3330

3431
// Update the wiki
3532
Promise.all([getLastRevision(), getToken()])
3633
.then(([lastId, token]) => putWiki(lastId, token))
3734
.catch((err) => (console.error(err), process.exit(1)));
3835

39-
//#region functions
40-
4136
/**
4237
* Get the last revision ID on the Wiki. Required otherwise editing the wiki fails
4338
*/
@@ -96,12 +91,11 @@ function putWiki(lastId, token) {
9691
*/
9792
function fixContent(content) {
9893
// Fix updated timestamp
99-
content = content.replace(/\!\[Updated\](.*?)square\)/g, `#### Updated: ${moment().format('MMMM Do YYYY')}`);
94+
content = content.replace(/\!\[Updated\](.*?)square\)/g, `#### Updated: ${DateTime.now().toFormat('MMMM dd, yyyy')}`);
10095

10196
// Fix published timestamps
10297
content = content.replace(/\!\[Published\]\(https\:\/\/img\.shields\.io\/badge\//g, '**');
10398
content = content.replace(/-informational\?style=flat-square\)/g, '**');
10499

105100
return content;
106101
} // * If this is highlighted weirdly, it's because of the 'updated timestamp' regex, don't worry about it
107-
//#endregion

0 commit comments

Comments
 (0)